How to push changes to remote repository with git

Posted in Tutorials

Tweet This Share on Facebook Bookmark on Delicious Digg this Submit to Reddit

Suppose that you have committed changes to your local master branch and want to push these changes to the remote repository using git.  Atlassian has a great tutorial on this.

1.  First you have to synchronize your local master branch with the remote repository.  Switch to your local master branch …

git checkout master

2. You want to fetch any changes that was made in the remote repository with …

git fetch origin

and see what changes was made in the remote master branch …

git log origin/master

3.  And merge those changes to your local master branch …

git merge origin/master

This merges the remote master “origin/master” to your current branch.

4. An alternative shortcut is to use …

git pull origin

which is equivalent to …

git fetch origin
git merge origin/master

 

5.  At this point your local master is in sync with remote master branch.  If not, the following command would not work.  You are ready to push your local changes to remote.

git push origin master

This pushes your local master branch to origin.

Or …

git push origin –all

This pushes all branches.

And

git push origin –tags

pushes the tags as well.