簡體   English   中英

git子樹無用合並

[英]git subtree useless merge

我這樣在我的項目演示中添加了一個子樹

$ 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

到目前為止,我對subtree感到滿意。 然后我將文件編輯到子樹插件中,並提交和子樹推送

* 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

我發現后,我通過更新plugone從我的項目演示 git subtree push --prefix=plugins/plugone plugone master ,當我運行

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

我希望它什么也不做,但是我注意到演示項目中有新的提交:

*   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

這非常令人尷尬,因為這意味着我和我的同事們必須在每次git子樹推送之后都運行git子樹pull ,這對IMO來說意義不大。

如何預防這種行為?

確實存在另一種方法可以執行此操作,但是要困難一點(要運行更多命令)。 而不是使用 ,我嘗試了git read-tree / merge ,它給了IMO更好的東西...

好處是我不需要安裝額外的工具...

這是一篇很有幫助的文章,很好地描述了如何手動使用子樹概念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