Updating with local changes

suggest change

When local changes are present, the git pull command aborts reporting :

error: Your local changes to the following files would be overwritten by merge

To update anyway, stash the local changes, rebase onto what you fetch, then restore the stash:

git stash
git pull --rebase 
git stash pop

A convenient way could be to define an alias using :

git config --global alias.up '!git stash && git pull --rebase && git stash pop'

The next alias replaces the previous one. pull.rebase with --autostash stashes and restores for you (Git 2.9 and later):

git config --global alias.up 'pull --rebase --autostash'

Next you can simply use :

git up

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents