Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
docs:git:working_copies_of_multiple_branches [2009/11/08 00:23] – billh | docs:git:working_copies_of_multiple_branches [2009/11/08 01:07] (current) – billh | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== working copies of multiple branches ====== | ====== working copies of multiple branches ====== | ||
- | Sometimes during development we need to have working copies of more than one branch at the same time. With svn this was simple, because working copies of each branch (and/or trunk) would exist at the same time after a checkout. | + | Sometimes during development we need to have working copies of more than one branch at the same time. With svn this was simple, because working copies of each branch (and/or trunk) would exist at the same time after a checkout. |
- | + | ||
- | A single working copy using git would only reflect the active | + | |
(assume master working copy/repo is at / | (assume master working copy/repo is at / | ||
+ | |||
+ | ===== simple solution ===== | ||
+ | I want to work on an upstream branch other than " | ||
+ | < | ||
+ | cd /foo/base | ||
+ | git branch alt | ||
+ | (make sure you have a branch called ' | ||
+ | cd .. | ||
+ | git clone /foo/base /foo/alt | ||
+ | cd /foo/alt | ||
+ | git branch -a | ||
+ | (see that alt is not there because only master is tracked; unless another branch was active!) | ||
+ | git checkout --track -b alt origin/alt | ||
+ | (this creates a local branch ' | ||
+ | copy to that branch; git push, git fetch, git pull are all configured automatically) | ||
+ | git pull | ||
+ | git push origin alt | ||
+ | (you can also just run 'git push' unless you don't want to update other branches) | ||
+ | </ | ||
+ | |||
+ | Your .git/config file will show the alt branch configured like this:< | ||
+ | [branch " | ||
+ | remote = origin | ||
+ | merge = refs/ | ||
+ | </ | ||
+ | |||
+ | ===== manual solution ===== | ||
+ | :!:Please use the " | ||
+ | |||
+ | My preference for doing this with git was to have a " | ||
+ | |||
< | < | ||
mkdir /foo/alt | mkdir /foo/alt | ||
Line 47: | Line 76: | ||
</ | </ | ||
- | ===== adding git pull capability ===== | + | ===== manually |
git pull actually does a git fetch then a git merge operation for you. If you want to also be pulling (merging) any changes that occur on this alt branch on the main repo (/ | git pull actually does a git fetch then a git merge operation for you. If you want to also be pulling (merging) any changes that occur on this alt branch on the main repo (/ | ||
git config branch.alt.remote origin | git config branch.alt.remote origin | ||
Line 60: | Line 89: | ||
You should now be able to 'git pull' and merge any changes from the main repo. | You should now be able to 'git pull' and merge any changes from the main repo. | ||
+ | |||
+ | ===== External Links ===== | ||
+ | * [[http:// | ||
+ |