Reputation: 1623
I have a git workflow that involves at least two branches, "master" and "staging". When I'm content with what I've put into master, I want to push it to a staging server for others to review, and for that to happen, I need to bring the "staging" branch up to date with the "master" branch.
Currently, I have to do this:
git checkout staging
git merge master
git checkout master
Is there any way for me to merge my current branch into the staging branch in one command?
Upvotes: 1
Views: 627
Reputation: 1623
If you don't care what is currently on staging
and only want to force it to point to the same commit as master:
git update-ref refs/heads/staging refs/heads/master
https://git-scm.com/docs/git-update-ref
Upvotes: 0
Reputation: 22832
In case the merge fails you probably want to handle the conflicts. And as such you need to be checked out at the staging branch, otherwise where will the conflicting files be?
What you could do is create a shell alias for the process:
alias updateStage="git checkout staging && git merge master && git checkout master"
In case the merge fails git-merge
will return 1
and it won't attempt to checkout master back, leaving you free to resolve the conflicts.
Upvotes: 1