简体   繁体   中英

How to mark a git branch as merged?

I know this sounds a little weird, but sometimes manually editing is more convenient than merging and resolving conflicts. I would like GitHub/GitLab to show a merged label on the branches I manually "merged". Can I do that?

One way you can do this is to actually do a git merge , but use the -s ours merge strategy to ignore any actual contribution from the branch. From the git merge documentation :

ours

This resolves any number of heads, but the resulting tree of the merge is always that of the current branch head, effectively ignoring all changes from all other branches. It is meant to be used to supersede old development history of side branches. Note that this is different from the -Xours option to the recursive merge strategy.

This would be suitable to use after you have manually edited a branch to "merge" it, but then want to inform Git that the branch has in fact been logically merged.

Note: This works only if you have a pull request open for that branch.

You'll have to do a fast-forward merge:

(master)$ git merge <your-branch> --no-ff
(master)$ git push origin master

Now your branch should be labeled as merged . I don't think it will work without the creation of a pull request at least for GitHub.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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