Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
777 views
in Technique[技术] by (71.8m points)

merge - Git Workflow short-lived feature branch with squash

I have a questions concerned about the following git workflow:

 - checkout master
 - pull -r origin master
 - checkout new_feature
 - rebase master
 - checkout master
 - merge --squash new_feature
 - commit -m "F"
 - push origin master

Now you will end up with the following setup, assuming some commits C,D,E happened on the new_feature branch:

Master             A --B --------------- F
                     
new_feature           -- C -- D -- E

Local Master and Origin Master pointing to F. The F commit involves C,D,E.

Now I want to delete the new_feature Branch by running:

branch -d new_feature

error: The branch 'new_feature' is not fully merged. If you are sure you want to delete it, run 'git branch -D new_feature'.

Why do I get the error here and why does git not know, that the branch has been fully merged, just with the squash command?

(even a git diff does not show any differences)

question from:https://stackoverflow.com/questions/66062465/git-workflow-short-lived-feature-branch-with-squash

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Well, with these commands the new_feature branch is not formally merged, in the sense that it is not a parent node of the merged commit. What git will not check is that your changes have actually been merged. You know, but for git it is not trivial to know.

I have tried your workflow, then I have re-merged again the squashed-merged branch and then it can be deleted.

It is actually not an error, it is a check to prevent that you lose your work.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...