Use `git stash` to Save Local Changes While Pulling

Chris Achard
InstructorChris Achard

Share this video with your friends

Send Tweet

If we make a change to the same function both locally and remotely, then when we try to pull down the remote changes, we'll run into a conflict - and git won't pull the remote changes down.

So first, we'll use git stash to stash the local changes, and then git pull to get the remote changes. To apply the stashed changed, we'll then use git stash pop

Since we changed the same function however, we'll get a merge conflict! So we'll fix the merge conflict, and then add and commit that change.

Finally, we'll drop the change from the stash with: git stash drop stash@{0}