Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision | |||
docs:git:starting_a_new_remote_branch [2010/04/04 11:07] – billh | docs:git:starting_a_new_remote_branch [2010/07/28 16:08] (current) – billh | ||
---|---|---|---|
Line 2: | Line 2: | ||
In the examples below, there is a shared repo (shared), a user1 (doing the branch changes), and a user2 (needs to pull the branch changes). | In the examples below, there is a shared repo (shared), a user1 (doing the branch changes), and a user2 (needs to pull the branch changes). | ||
- | Method | + | Method |
- | ===== method 1: push a new branch | + | |
+ | ===== method 1: start a local branch | ||
* shared repo has one branch: master | * shared repo has one branch: master | ||
- | * user1 pushes | + | * user1 creates |
- | $ git push origin origin: | + | $ git checkout -b dev |
</ | </ | ||
- | * user1 now has the following branches locally:< | + | * push the new local branch to the shared repo:< |
- | $ git branch -a | + | $ git push origin dev |
- | + | ||
- | * master | + | |
- | remotes/origin/HEAD -> origin/ | + | |
- | remotes/ | + | |
- | remotes/ | + | |
</ | </ | ||
- | * user1 now must create a local branch | + | * but wait - even though |
+ | * option 1 - use %%--set-upstream%%< | ||
+ | git branch --set-upstream dev origin/ | ||
+ | (output should be: Branch dev set up to track remote branch | ||
+ | </code> | ||
+ | * option 2 - delete the local branch and create it again with %%--track%%< | ||
+ | $ git checkout master | ||
+ | $ git branch -D dev | ||
$ git checkout --track -b dev origin/dev | $ git checkout --track -b dev origin/dev | ||
- | $ git branch | + | </ |
- | + | * option 3 - manually edit your .git/config by adding lines similar to the following (this is what %%--set-upstream%% does for you)< | |
- | * dev | + | [branch "dev"] |
- | | + | remote = origin |
- | remotes/origin/HEAD -> origin/ | + | merge = refs/heads/dev |
- | | + | |
- | remotes/ | + | |
</ | </ | ||
* user2 can pull changes to see the new branch, then use the same command as user1 to create a local branch and track the remote branch:< | * user2 can pull changes to see the new branch, then use the same command as user1 to create a local branch and track the remote branch:< | ||
Line 44: | Line 45: | ||
</ | </ | ||
- | ===== method 2: start a local branch | + | ===== method 2: push a new branch |
* shared repo has one branch: master | * shared repo has one branch: master | ||
- | * user1 creates | + | * user1 pushes |
- | $ git checkout -b dev | + | $ git push origin origin: |
</ | </ | ||
- | * push the new local branch to the shared repo:< | + | * user1 now has the following branches locally:< |
- | $ git push origin dev | + | $ git branch -a |
+ | |||
+ | * master | ||
+ | remotes/origin/HEAD -> origin/ | ||
+ | remotes/ | ||
+ | remotes/ | ||
</ | </ | ||
- | * but wait - even though | + | * user1 now must create a local branch |
- | * option 1 - delete the local branch and create it again with --track< | + | |
- | $ git checkout master | + | |
- | $ git branch -D dev | + | |
$ git checkout --track -b dev origin/dev | $ git checkout --track -b dev origin/dev | ||
- | </ | + | $ git branch |
- | * option 2 - manually edit your .git/config by adding lines similar to the following< | + | |
- | [branch | + | * dev |
- | remote = origin | + | |
- | merge = refs/heads/dev | + | remotes/origin/HEAD -> origin/ |
+ | | ||
+ | remotes/ | ||
</ | </ | ||
* user2 can pull changes to see the new branch, then use the same command as user1 to create a local branch and track the remote branch:< | * user2 can pull changes to see the new branch, then use the same command as user1 to create a local branch and track the remote branch:< |