Keep your git repository updated with a friend’s repository

This is the way I use to keep my repository in sync when working on a project together with a friend:

Clone your main project:

$ git clone git.yourproject.com/projectname.get

Add your friend repository:

$ git remote add yourfriend git.yourfriend.com/hisprojectname.git

Create a new branch to receive your friend modifications:

$ git branch develop
$ git checkout develop

Pull the commits from your friend repository:

$ git pull yourfriend master

Return to you master branch and merge modifications:

$ git checkout master
$ git merge develop

Send modifications to your repository:

$ git push origin master

Other alternative:

$ git remote add yourfriend git.yourfriend.com/hisprojectname.git

$ git fetch yourfriend

$ git rebase yourfriend/master

$ git push origin master

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