I have a project "A" that is a Git repository. I would like to be able to make multiple copies of project A (B and C), and modify them for clients.
"A" is the master so sometimes when I do new functionality i would like to be able to pull them into B or C. But some commits should just stay in A and only be used if making a new clone.
How do I do that with Git? That is:
- how to copy A? (Clone?)
- how to get specific commits into B and C?
Please keep in mind that this all happening locally - not on GitHub. I u开发者_StackOverflow社区se OS X.
- how to copy A?
git clone
is the way, meaning you establish a publication link between A and B,C, allowing for pushing/pulling commits between them.
- how to get specific commits into B and C?
By having in the repo A:
- private branches where you develop as many feature you want (but this branch is never pushed anywhere else)
- public branch which will be pushed to B and C
- merge or
rebase --onto
your commits from your private branch on top of your public branch, then push that public branch to B or C.
One workflow would be for instance:
cd ~/projectA
git checkout master
git branch private
# do some commits, some private, some useful to a
git checkout master
git branch feature_for_a
git cherry-pick sha1_from_private
cd ~/project_B
git fetch project_A
git checkout --track feature_for_a # check modifs for a
git checkout master
git merge feature_for_a
# do some client specific modifications
精彩评论