we are pretty unexperienced in using GIT. Actually we like the idea of branches ;-) But somehow all merges from one user just don't close the branch...
You can look at the image here: http://i54.tinypic.com/297i14.png
There is a grey and a blue line which just got straight forward... even after the merge... So what is he doing wrong? Any clues? I don't want imagin what happens if he creates some more branches and all of them persist in the history view even after a merge...
Thank you very much!
In a good workflow, the feature branch is deleted once its merged back into master. New branches should be created for each new feature(s) that you work on.
You can use the git reset --merge command. You can also use the git merge --abort command. As always, make sure you have no uncommitted changes before you start a merge.
There are times when you get an “not fully merged” error for a git branch, usually when trying to delete a local branch from your machine. It's a safe bet that something in your local branch has not actually made it to the remote repository and we should do some investigating.
When you do a merge, the new commit only moves forward your current branch. The branch name that pointed to the other branch is left where it was. In other words, if you have this situation:
A---B---C blue
\
D---E---F grey
... and do:
git checkout blue
git merge grey
You'll end up with:
A---B---C---G blue
\ /
D---E---F grey
If you want to remove the grey
branch you can then do git branch -d grey
. This won't affect the commit graph, just remove the branch - they're like labels that get moved around the commit graph.
However, if you carry on and create more commits on the grey
and blue
branches, those lines will continue:
A---B---C---G---H---I blue
\ /
D---E---F---J---K---L grey
In the image you link to, I assume that either there are further commits further above the section you've shown, or the tool you're using is just presenting the commit graph strangely.
I am not certain what you mean by closing the branch, but I'll make a guess :)
It is still possible to use a branch even after a merge has been done. I guess this is per design and how it should be. For instance you might want to continue working with the branch even after a merge has been done, say in order to continue focusing on development in that branch. That is why it still shows up in the image you referred to.
If you don't want to do that, it is possible to delete the branch after merging, which closes it definitively by issuing the command git branch -d <branch>
while being in another branch, like master. (This will only delete the branch if its latest commit has been merged with the branch you have active, so there is no risk of losing data.)
Currently git requires a two step process for the merging and closing of a 'task' branch where the merge nominally indicates closure of the task and that the branch is no longer required.
It maybe that it would be a useful option for some to be able to delete a branch's refs/heads entry so closing everything in one step [make a proposal to the git list?]. However I'm sure that many workflows have instances where they want the ability to go back and tidy up some minor issue, which an early deletion would make awkward. (though it would be in the reflog for a while)
Give the user the task of creating an alias or script to combine the two actions. It will help the education all round ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With