Instead of 'git pull', if you know you don't want to keep any local changes

fast-forward (read more about this)

merge - Can I make fast forwarding be off by default in git? - Stack Overflow

git fetch && git reset

git fetch origin main && git reset --hard origin/main

"Considering the definition of git pull is git fetch && git merge, the merge isn't unexpected." -

Also see: version control - What is the difference between 'git pull' and 'git fetch'? - Stack Overflow

Our alternative approach has become git fetch; git reset --hard origin/master as part of our workflow. It blows away local changes, keeps you up to date with master BUT makes sure you don't just pull in new changes on top on current changes and make a mess. We've used it for a while and it basically feels a lot safer in practice. Just be sure to add/commit/stash any work-in-progress first ! -

git pull --rebase

git pull --rebase

git pull is just a shorthand for git fetch + git mergegit pull --rebase is git fetch + git rebase instead.


No, they are quite different.


Pages that link to this page