I like git pull --rebase
, but it doesn't work when there are local changes. So I wrote a script (named safepull
) to stash the local changes while the rebase is running:
git stash push -m 'Hide from pull-rebase'
git pull --rebase
git stash pop
However, if by chance there are no local changes, git stash push
does nothing, but git pull
still takes an existing stash entry and applies it, and it's almost certainly an unwanted one.
How can I pull --rebase
regardless of whether there are local changes or not? I thought of forcing git stash push
to create an empty stash entry, but apparently there is no way to do it. git
's exit code is zero (success) regardless of whether a stash entry was created or not.
Any ideas?