If I'm on a local branch and pull from remote, and then try to switch to a different branch, it tells me to commit or stash changes first. I figured that when I do the pull, I'd be getting all the new commits from the remote branch, and that my local branch would just be up-to-date with the remote. If I do an additional commit after this pull, the only new information I'd be adding is that I did the pull. Can I just pull without having to add a commit message after?
-
1Either you had changes _before_ the pull or you had a merge conflict which you need to resolve. – tkausl Apr 07 '23 at 21:06
-
You're right, I did have a local change I didn't notice. Thanks. – gkeenley Apr 07 '23 at 21:16
-
Do not include a "solution" in the question. The place for a solution is the Answer field. Accept an answer, your own or someone else's, to indicate your solution. – matt Apr 08 '23 at 01:42
2 Answers
Git does NOT prompt you to commit/stash immediately after pulling from remote.
For this reason, I prefer setting a stash
+ pull --rebase
by default (Git 2.6+)
git config --global pull.rebase true
git config --global rebase.autoStash true
That way, a simple git pull
will replay (rebase) my local commits (the one not yet pushed) on top of the refreshed origin/myCurrentBranch
, making sure my local work is not overridden.
Any work in progress is automatically stashed first, then restored after the rebase.
Additionally, if I have "unsubmitted" work (local modification not yet added to the index and committed), the "autostash" part make sure the work in progress is saved before the pull, and re-applied after the pull.

- 1,262,500
- 529
- 4,410
- 5,250
I strongly prefer to do what VonC suggested more explicit and without any specific configuration:
git commit -am "==== before pull ====" # Temporary commit
git pull --rebase
git reset HEAD^ # Undo temporary commit
In case of conflicts, use KDiff3 to resolve them.

- 26,565
- 10
- 94
- 165