简体   繁体   English

git子树无用合并

[英]git subtree useless merge

I added a subtree into my project demo this way 我这样在我的项目演示中添加了一个子树

$ git subtree add --prefix=plugins/plugone plugone master --squash
$ tree .

demo
|___.git
|___plugins
       |___plugone

$ git log --oneline --all --graph --decorate

* 200e94c (HEAD -> master, origin/master) Merge commit 'f9a745bb60b3e5816f918c0ec736714bd362bce7' as 'plugins/plugone'
| \
|  * f9a745b Squashed 'plugins/plugone/' content from commit 5c4a153
* 947ebfe bla bla

So far so good, I'm happy with subtree . 到目前为止,我对subtree感到满意。 Then I edited a file into the subtree plugone and committed and subtree push ed 然后我将文件编辑到子树插件中,并提交和子树推送

* 07b3046 (HEAD -> master, origin/master) plugone append #1
* 200e94c Merge commit 'f9a745bb60b3e5816f918c0ec736714bd362bce7' as 'plugins/plugone'
| \
|  * f9a745b Squashed 'plugins/plugone/' content from commit 5c4a153
* 947ebfe bla bla

I noticed that after I updated plugone from my project demo through git subtree push --prefix=plugins/plugone plugone master , when I run 我发现后,我通过更新plugone从我的项目演示 git subtree push --prefix=plugins/plugone plugone master ,当我运行

$ git subtree pull --prefix=plugins/plugone plugone master --squash

I expected this to do nothing , but I noticed new commits in the demo project: 我希望它什么也不做,但是我注意到演示项目中有新的提交:

*   a5ab686 (HEAD -> master) Merge commit 'c8cd6206950dc45196cf6fd1f17e8587a115fee6'
|\
| * c8cd620 Squashed 'plugins/plugone/' changes from 5c4a153..1fd84fe
* | 07b3046 (origin/master) plugone append #1
* |   200e94c Merge commit 'f9a745bb60b3e5816f918c0ec736714bd362bce7' as 'plugins/plugone'
|\ \
| |/
| * f9a745b Squashed 'plugins/plugone/' content from commit 5c4a153
* 947ebfe blabla

This is very embarrassing because it means that my colleagues and I have to run git subtree pull after every git subtree push which IMO doesn't make much sense. 这非常令人尴尬,因为这意味着我和我的同事们必须在每次git子树推送之后都运行git子树pull ,这对IMO来说意义不大。

How to prevent this behavior ? 如何预防这种行为?

Well another way does exist to do that but in a bit harder way (more command to run). 确实存在另一种方法可以执行此操作,但是要困难一点(要运行更多命令)。 Instead of using , I tried git read-tree/merge and it gives something IMO nicer... 而不是使用 ,我尝试了git read-tree / merge ,它给了IMO更好的东西...

The advantage is that I don't need to install extra tools... 好处是我不需要安装额外的工具...

Here is a helpful article that describes well how to use subtree concept manually https://delicious-insights.com/en/posts/mastering-git-subtrees/#subtrees-step-by-step 这是一篇很有帮助的文章,很好地描述了如何手动使用子树概念https://delicious-insights.com/en/posts/mastering-git-subtrees/#subtrees-step-by-step

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM