Create a new Git Remote Repository

The following steps are creating a remote Git Repositories and push a local copy of a project into the newly created repositories:

#On local machine
if you want to ignore some files or folders from putting them in the repository, you could create a .gitignore file before running git add .
$ cd foo_project
$ git init
$ git add *
$ git commit -m "initial msg"
(Do not forget to do this step, or you will enconter "Git error: src refspec master does not match any")


Now, create the repository on your Git server. All of my git repositories are located at /usr/local/git_root/ of the remote server
#On remote machine
$ mkdir git_root/
$ cd /usr/local/git_root/


Create your new project git repo as a bare Git repository

$ mkdir project_name.git
$ cd project_name.git/
$ git --bare init

Make sure permissions are set properly. These are common options I use for my shared repositories

$ git config core.sharedrepository 1
$ git config receive.denyNonFastforwards true
$ find objects -type d -exec chmod 02770 {} \;

#The core.sharedrepository flag tells git to keep everything group readable and writable.
#The receive.denyNonFastforwards flag makes sure that merges can't happen when you push to the repo.
You have to do the merges on your local machine, and then push the result.

Now, go back to your local repository, and add the newly created remote repository so it tracks from the remote repository (origin).
#On local machine, in your git project
adding a remote by:

git remote add origin ssh://ip_address_of_remote_server/usr/local/git_root/project_name.git
git remote add origin user_name@ip_address:/usr/local/git_root/EMAN2.git
(I used this command in my case)
git push -u origin master

No comments:

Post a Comment

Datatable static image not found on the server

When you use ```datatables.min.css``` and ```datatables.min.js``` locally, instead of datatables CDN, you may have encountered that ```sort...