master branch and ‘origin/master’ have diverged, how to ‘undiverge’ branches’?

You can review the differences with a: before pulling it (fetch + merge) (see also “How do you get git to always pull from a specific branch?”) When you have a message like: “Your branch and ‘origin/master’ have diverged, # and have 1 and 1 different commit(s) each, respectively.” , check if you need to update origin. If origin is up-to-date, then some commits … Read more

How do you create a remote Git branch?

Simple Git 2.0+ solution: As of Git 2.0, the behavior has become simpler: You can configure git with push.default = current to make life easier: I added this so now I can just push a new branch upstream with -u will track remote branch of the same name. Now with this configuration, you will auto-guess the remote reference to … Read more

Why do I have to “git push –set-upstream origin “?

TL;DR: git branch –set-upstream-to origin/solaris The answer to the question you asked—which I’ll rephrase a bit as “do I have to set an upstream”—is: no, you don’t have to set an upstream at all. If you do not have upstream for the current branch, however, Git changes its behavior on git push, and on other commands as well. The … Read more

Make an existing Git branch track a remote branch?

Given a branch foo and a remote upstream: As of Git 1.8.0: Or, if local branch foo is not the current branch: Or, if you like to type longer commands, these are equivalent to the above two: As of Git 1.7.0 (before 1.8.0): Notes: All of the above commands will cause local branch foo to track remote branch foo from remote upstream. The old (1.7.x) … Read more

How to pull a specific branch from Github

If you did a clone, then all branches should be available to you. You need to checkout the branch. git checkout todo-mvvm-databinding If the branch isn’t available for whatever reason, then you can create it and then pull it: git checkout -b todo-mvvm-databinding (-b specifies “create branch”) git pull origin todo-mvvm-databinding will fetch and merge this branch into … Read more

How do you create a remote Git branch?

Simple Git 2.0+ solution: As of Git 2.0, the behavior has become simpler: You can configure git with push.default = current to make life easier: I added this so now I can just push a new branch upstream with -u will track remote branch of the same name. Now with this configuration, you will auto-guess the remote reference to … Read more

Why do I have to “git push –set-upstream origin “?

TL;DR: git branch –set-upstream-to origin/solaris The answer to the question you asked—which I’ll rephrase a bit as “do I have to set an upstream”—is: no, you don’t have to set an upstream at all. If you do not have upstream for the current branch, however, Git changes its behavior on git push, and on other commands as well. The … Read more