Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark a git branch as merged?

Tags:

git

github

gitlab

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?

like image 887
Michael Ma Avatar asked Apr 20 '17 03:04

Michael Ma


People also ask

How do you merge branches in git?

To merge branches locally, use git checkout to switch to the branch you want to merge into. This branch is typically the main branch. Next, use git merge and specify the name of the other branch to bring into this branch.

How do I know if a branch is merged?

You can use the git merge-base command to find the latest common commit between the two branches. If that commit is the same as your branch head, then the branch has been completely merged.

How do I merge a GitHub main branch?

In GitHub Desktop, click Current Branch. Click Choose a branch to merge into BRANCH. Click the branch you want to merge into the current branch, then click Merge BRANCH into BRANCH. Note: If there are merge conflicts, GitHub Desktop will warn you above the Merge BRANCH into BRANCH button.


1 Answers

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.

like image 87
Greg Hewgill Avatar answered Oct 05 '22 00:10

Greg Hewgill