Why does my GitHub repository say 'Changes must be committed or stashed' before pulling?
This error occurs if you have uncommitted changes. Git requires all changes be committed or stashed to maintain a clean state for pulling updates.
When you see 'Changes must be committed or stashed,' Git is indicating that local changes need handling before it can pull from the remote branch. This is because Git prioritizes a clean working directory for seamless merging. To proceed, either commit your changes with git commit -m 'your message'
, or stash them using git stash
, which saves changes temporarily without a commit. After stashing, you can pull updates with git pull
and later reapply your stashed changes using git stash apply
. This process maintains local and remote coherence, preventing merge conflicts and ensuring the repository's history is intact.