Programming

Git: push/pull new branches to/from a remote repository

To push the branch newbranch to the remote repository origin:

$ git push -u origin newbranch

The -u option (we can also use the more verbose --set-upstream option) tells Git to also track this branch, thus allowing us to pull automatically future upstream commits using git pull.

To pull the branch newbranch from a remote repository origin, we first update our local repository:

$ git fetch origin

Then we create a local branch called newbranch and set it to track the upstream one:

$ git checkout --track origin/newbranch

Back


Comments

No comment yet.

A remark, a suggestion? Do not hesitate to express yourself below. Just be courteous and polite, please.

If this field is left blank, you will appear as Anonymous.