views:

60

answers:

2

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 the following:

git checkout master
git merge dev
git checkout dev

That's awfully verbose, and since I do it frequently, I'd like to minimize it. Is there any one git command I can use to merge from my current branch dev to the other branch master without having to checkout the master branch first? Something maybe like:

git merge dev to master

would be awesome. I looked through the git documentation and didn't see anything.

+1  A: 

git push dev master

David
So... you want to push the dev branch to a remote called "master"? Usually master is a branch, not a remote...
Jefromi
+2  A: 

Your best bet would be to just use an alias, placed in your global gitconfig (~/.gitconfig):

[alias]
    merge-to = "!f() { git checkout $1 && echo git merge $2 && echo git checkout -; }; f"

so that you can invoke it from any repository as

git merge-to master dev
Jefromi