Let's say, I have a branch with my own changes and one commit. But the remote branch is a few commits ahead as well. What is the best way to merge in the remote changes locally, not to generate merge commits?
You can use a rebase (git rebase):
git checkout branch
git fetch origin
git rebase origin/branch
You will replay your commits on top of the updated remote tracking branch origin/branch (replace branch by the actual name of the branch)
Even shorter:
git pull --rebase origin branch
That is valid since you haven't yet pushed 'branch', and will allow you to resolve any merge issue locally.
You can do a simple merge, or you can rebase your changes on the remote branch
L1: local commit
B-C-D Remote commits
A--L1
\
B--C--D
A--B--C--D--L1
do a simple fetch and then rebase.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With