Git子树工作流程 [英] Git subtree workflow
问题描述
在我目前的项目中,我使用的是开源论坛( https://github.com/vanillaforums/Garden )。我打算做这样的事情:
git remote add vanilla_remote https://github.com/vanillaforums/Garden.git
git checkout -b vanilla vanilla_remote / master
git checkout master
git read-tree --prefix = vanilla -u vanilla
通过这种方式,我可以对vanilla文件夹进行更改(如更改配置)并将其提交给我的主分支,并且还可以切换到我的vanilla分支以获取更新。我的问题是当我尝试将分支合并在一起时
git checkout vanilla
git pull
git checkout master
git merge --squash -s subtree --no-commit vanilla
git commit -a -m更新提交
问题在于更新提交会在我的提交之上并覆盖我的更改。我宁愿让我的提交在更新之上重播。有没有简单的方法来做到这一点?我不擅长git,所以也许这是错误的做法。此外,我真的不想把我的历史与香草历史混为一谈。 我完成了这个计划:
-
在我的开发分支上触摸子树中的文件。
使用压扁的开发提交更新子树分支: > -
使用其远程存储库更新子树分支。 更新开发压缩子树提交:
git merge --squash -s subtree --no-commit subtree
git merge -s子树--squash --no-commit 开发
< blockquote>
In my current project I'm using an open source forum ( https://github.com/vanillaforums/Garden ). I was planning on doing something like this :
git remote add vanilla_remote https://github.com/vanillaforums/Garden.git
git checkout -b vanilla vanilla_remote/master
git checkout master
git read-tree --prefix=vanilla -u vanilla
This way I can make change into the vanilla folder (like changing config) and commit it to my master branch and I can also switch into my vanilla branch to fetch updates. My problem is when I try to merge the branch together
git checkout vanilla
git pull
git checkout master
git merge --squash -s subtree --no-commit vanilla
git commit -a -m "update commit"
The problem is that the "update commit" goes on top of my commits and "overwrite" my change. I would rather like to have my commits replay on top of the update. Is there a simple way to do that? I'm not very good in git so maybe this is the wrong approach. Also, I really don't want to mix my history with the vanilla history.
I finished up with this scheme:
Work on my development branch touching files from the subtree.
Update the subtree branch with squashed development commits:
git merge -s subtree --squash --no-commit development
Update the subtree branch with its remote repository.
- Update development with squashed subtree commits:
git merge --squash -s subtree --no-commit subtree
这篇关于Git子树工作流程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!