← Back to list

Two Easy Ways to Resolve Uncommitted Changes in Git: Commit or Stash?

As a developer, I often find myself in a situation where I’m trying to pull the latest changes from a Git repository, only to be blocked by…

Fz Fawzi · 2024-09-06 21:30 · 0 claps · 1.4 min read
#git #github #tips
Open on Medium ↗
Wiki topics: 🔓 · Open Source

Two Easy Ways to Resolve Uncommitted Changes in Git: Commit or Stash?

Photo by Roman Synkevych on Unsplash

Photo by Roman Synkevych on Unsplash

As a developer, I often find myself in a situation where I’m trying to pull the latest changes from a Git repository, only to be blocked by uncommitted changes in my working directory. This can be frustrating, especially when you’re in the middle of something and need the latest updates. After running into this issue multiple times, I decided to take proper notes on how to resolve it effectively, and I’m sharing those here to save others the trouble of figuring it out on the go.

This error occurs because you have uncommitted changes in your working directory, and Git is preventing you from merging new changes until you handle these local changes. You have two main options:

Option 1: Commit Your Changes

  1. Stage Your Changes: Run the following command to stage all your changes :
git add .
  1. Commit your changes : After staging, commit your changes with a message :
git commit -m "Your commit message"

This will save your changes with a commit in your local repository .

  1. Pull the Changes : Now that your local changes are committed, you can pull the latest update from the remote repository:
git pull

Option 2: Stash Your Changes

If you don’t want to commit your changes yet, you can stash them temporarily:

  1. Stash Your Changes : Run the following command to stash your changes, which will revert your working directory to the last commit :
git stash
  1. Pull the Changes : After stashing, you can pull the latest changes:
git p
  1. Apply the Stashed Changes : Once the pull is complete, reapply your stashed changes :
git stash pop

If there are any conflicts when applying the stash, Git will notify you, and you’ll need to resolve them manually.

After following either of these options, your local repository should be synchronized with the remote one.


메타데이터
post_id
bbe154e26c8b
slug
two-easy-ways-to-resolve-uncommitted-changes-in-git-commit-or-stash-bbe154e26c8b
url
https://medium.com/@fzfawzi/two-easy-ways-to-resolve-uncommitted-changes-in-git-commit-or-stash-bbe154e26c8b
canonical_url
https://medium.com/@fzfawzi/two-easy-ways-to-resolve-uncommitted-changes-in-git-commit-or-stash-bbe154e26c8b
author_url
https://medium.com/@fzfawzi
status
ok
fetched_at
2026-07-22 22:17:30