How do you push your changes to a new remote repository if you created the local repository with “git init”? Most developers probably start their projects using git on their local hard disk. When it comes time to making a remote repository for other people to pull from do the following:
Make a bare bone git repository on the server and then push to it from the head of your local repository:
ssh your-user@www.your-server.com
mkdir -p ~/some-path/…/…/your-repo.git
cd ~/some-path/…/…/your-repo.git
git –bare init
exitcd your-local-git-repository
git remote add origin your-user@www.your-server.com:some-path/…/…/your-repo.git
git push origin master
Notice the syntax of the “remote add”. There is no “ssh://” as shown in some tutorials. And it’s important to avoid hard coding the path on the remote server by using the colon. If you get a
“fatal: ‘your-repo.git’ does not appear to be a git repository“
error when doing the push you can remove the origin with the command “git remote rm orgin” and continue trying the add until you get it right.
Notes:
- You probably need to set up your ssh keys first as described in a past post here.
- The first part of this git tutorial started here.
[...] 2 is here. Comments [...]
Pingback by My git Tutorial For Ubuntu: PART 1 « Ivor O’Connor — August 11, 2009 @ 7:32 pm
[If you get a “fatal: ‘your-repo.git’ does not appear to be a git repository“
error when doing the push you can remove the origin with the command “git remote rm orgin” and continue trying the add until you get it right.] it is what i am doing for last 30 minutes. Thanks! Good advice!
Comment by Da — June 25, 2011 @ 1:06 pm