Skip to content

Push commits

benoitbleuze edited this page Aug 25, 2012 · 2 revisions
  • As we've seen, pushing the code to our repository should be simple since our code was based on the same commit c3df0e6 and we are just applying changes from there:
git push sharedRepo experimental:experimental
Counting objects: 4, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 339 bytes, done.
Total 3 (delta 0), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
To ../testRepo-bare.git/
   c3df0e6..c95e129  experimental -> experimental
  • The syntax for push is the following: git push name_of_the_remote_location local_branch_name:remote_branch_name

  • You can also leave out the remote branch name if you want to use the same branch name remotely.

  • If the branch you are trying to pull to was created locally this way: git checkout -b origin/someName then it was declared as automatically tracking the remote branch., and then just typing git pushwould have pushed it to the correct place.

  • Now you can also set your local branch to track a new remote one when you push to it:

ben@GregoryHouse:~/tmp/testRepo-clone (experimental)$ git push sharedRepo --set-upstream experimental:experimental
Branch experimental set up to track remote branch experimental from sharedRepo.
Everything up-to-date
  • from now on, when you pull or push without arguments from this branch, you will not need to specify the name. But if you are not a trustful person, always specify the remote and the local branch at least.

  • This was easy, we could fast forward our changes, but what about real world situation? when crazy coding happens and cross pushing happens?

Jump to Merge branches

Clone this wiki locally