Is there a way to write an alias that merges a branch back to its parent? I know I can do:
git checkout - && git merge -
But it only works in simple cases when my previous branch is the parent branch.
As far as I know git does not track this kind of information because there is no branches in there. But I hope it's already implemented as a plugin or a hookset.
Thanks in advance.
As VonC said first I need to do is to find parent of the current branch. The following script mostly does what I need:
What it does:
After that one just need to checkout to it and merge previous head into it:
PS: I didn't test it on large repositories and it can behave suprisingly if exists a branch of the current branch. It needs to be fixed.
Such an alias would involve first finding the "parent" branch.
It isn't trivial, and the question "Find the parent branch of a branch" has some good solutions.
Once you have the name of the parent branch, then you can use it in your alias.