1

It is a suggested practice to create a local git branch tracking the remote branch. My question is that why do we do that when we can actually pull down the remote branch and work on it directly with

git checkout origin/master ?

1
  • what if you don't have internet ? Jun 23, 2016 at 1:44

1 Answer 1

0

Well, if you work on top of origin/master with a local branch, you can push that new branch and it will create the new branch in the repo, but not cause the repo's master ref to get updated (so now there are commits on the DAG past the tip of master that master doesn't "know" about - probably not what you want since someone fetching origin's master wont get your new work to build on top of their master (they will actually get it, but it will look like work off on a branch). This probably is not what you wanted). But what if you really want the repo to update its master ref (which is the usual case)? Thats what a remote tracking branch is for. It says, when you push, update to remote ref to your remote tracking ref and when you pull, update your remote tracking ref to the remote's.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.