How to merge the current branch into another branch

前端 未结 8 941
忘了有多久
忘了有多久 2020-12-04 04:44

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

相关标签:
8条回答
  • 2020-12-04 05:39

    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
    
    0 讨论(0)
  • 2020-12-04 05:43

    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
    
    0 讨论(0)
提交回复
热议问题