I have two branches, master and dev. I always work on dev and only check code into the master branch once it\'s been approved for production use. When I do so, I have to do
Your best bet would be to just use an alias, placed in your global gitconfig (~/.gitconfig
):
[alias]
merge-to = "!f() { git checkout $1 && git merge $2 && git checkout -; }; f"
so that you can invoke it from any repository as
git merge-to master dev
This is old, but...
Combining the solutions from @kevin-lyda and @dmytrii-nagirniak above. this alias merges the current branch into the specified branch. It uses the remotes method with and uses git commands to get the context.
[alias]
merge-to = "!gitmergeto() { git push \"`git rev-parse --show-toplevel`\" `git rev-parse --abbrev-ref HEAD`:$1; } && gitmergeto"
To be used like:
git merge-to other-branch-name