When I want to merge one branch to another I use to do the following(in this example master to custom):
git checkout master && git pull && git checkout custom && git merge master
Can somebody suggest how to simplify this?
Thanks, Bogdan.
When I want to merge one branch to another I use to do the following(in this example master to custom):
git checkout master && git pull && git checkout custom && git merge master
Can somebody suggest how to simplify this?
Thanks, Bogdan.
It can not be simplified in the general case. Both the merge and the pull (which uses either a merge or a rebase) might need a working tree to allow the user to resolve potential conflicts.
There may be some simplifying assumptions that you can make though.
If your local master never has any local changes (i.e. every pull into your local master will always be a “fast-forward” update; possibly because the only reason you have a local master is because git clone automatically made one for you), then you can probably just ignore your local master and re-configure your local custom to pull from the same upstream that your local master uses.
# copy "upstream" config from 'master' to 'custom'
for o in remote merge rebase mergeoptions; do
v="$(git config branch.master."$o")" &&
git config branch.custom."$o" "$v"
done
Then, to merge the upstream into custom just do git checkout custom && git pull
.
Alternatively, you could work directly on your local master (move your custom commits to master with git checkout master && git reset --hard custom
, then you could abandon or delete custom).