Ivor O’Connor

August 11, 2009

My GIT Tutorial For Ubuntu: PART 2

Filed under: git — Tags: , , , , — ioconnor @ 6:36 pm

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
exit

cd 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:

  1. You probably need to set up your ssh keys first as described in a past post here.
  2. The first part of this git tutorial started here.
Advertisements

2 Comments »

  1. […] 2 is here. Comments […]

    Pingback by My git Tutorial For Ubuntu: PART 1 « Ivor O’Connor — August 11, 2009 @ 7:32 pm

  2. [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


RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at WordPress.com.

%d bloggers like this: