Reputation: 425
I create a local branch and I want to share it with my programming partner on the remote repository. We want to work on that branch for a while, before we finish the project and merge to the master.
Is there any problem with this (I start at my 'master'):
git checkout -b BRANCH
git commit -am "changes"
git push
He can pull the branch from the remote, right? When he push updates I can 'git pull' (when being checked in the BRANCH), am I right?
Why/When do I need to set tracking. Can I pull/push from the BRANCH without it?
Upvotes: 0
Views: 53
Reputation: 520918
Your workflow sounds completely OK to me, and is a typical workflow used by GitHub and a few of the other providers.
With regard to your confusion about having to set tracking, note that you created your branch using this:
git checkout -b BRANCH # on some other branch
You could have also created the same branch using this:
git branch --track BRANCH origin/BRANCH
In this alternative method of creating a branch, we explicitly tell Git that we want the local branch BRANCH
to track the remote branch also called BRANCH
. But doing it using your method, the tracking is set automatically, and we don't need to worry about it.
Using either method, our local branch BRANCH
is setup to point to the correct branch in the remote, so pulling and pushing should work with no issues.
Upvotes: 1