Local working changes are the files you edit on your computer before you save them to Git

When you work on a project in Git, your computer holds three separate versions of your files at the same time. The first is the version stored in your Git repository — the official record of what you committed. The second is the staging area, a holding space for changes you have marked to save next. The third is your local working directory, which is simply the files you see and edit in your folder right now. Local working changes are the edits you have made to those files since your last commit, whether you have told Git about them or not.

These changes exist only on your machine until you move them through the staging area and into a commit. Git tracks which files have changed, which lines within those files are different, and whether you have staged those changes for the next commit or left them unstaged. Understanding this three-part system is the foundation of using Git effectively, because it gives you control over exactly what goes into each commit.

Key Takeaways

  • Local working changes are edits you have made to files in your project folder that Git has not yet saved as a commit.
  • Git shows you which files have changed and which changes are staged (ready to commit) versus unstaged (not yet marked for saving).
  • You can view your changes with git status to see which files are modified, and git diff to see the exact lines that changed.
  • Staging changes with git add moves them from your working directory into the staging area, preparing them for a commit.
  • You can discard local working changes entirely with git checkout or git restore, reverting files back to their last committed state.

How Git tracks changes in your working directory

Every time you save a file in your editor, Git notices that the file has changed. It does not automatically record the change — it simply marks the file as modified. You can see this by running git status in your terminal, which lists all files that have been edited since your last commit. Files appear in two categories: staged changes, which you have marked for the next commit, and unstaged changes, which Git sees but you have not yet prepared to save.

Git compares your current files against the version stored in the repository. If a line is different, Git knows it changed. If you delete a line, Git records that deletion. If you add a line, Git records the addition. This comparison happens instantly and costs almost nothing, which is why Git can tell you the status of hundreds of files in a fraction of a second.

The key point is that Git does not force you to commit every change you make. You can edit ten files, commit five of them, and leave the other five sitting in your working directory unchanged. This separation between editing and committing is what makes Git flexible — you control when and what gets saved to history.

Viewing the exact lines that changed

Knowing that a file changed is useful, but often you need to see what actually changed. The command git diff shows you every line that is different between your working directory and the last commit. For each file, it displays the old version and the new version side by side, with additions marked in green and deletions marked in red.

If you have already staged some changes, git diff --staged shows you what is in the staging area waiting to be committed, while plain git diff shows only the unstaged changes still in your working directory. This distinction matters when you are reviewing your work before committing, because you might have staged part of your changes and left other edits unstaged.

For large files or many changes, the output can be long. You can pipe it to a pager like git diff | less to scroll through it, or use git diff filename to see changes in a single file. Some editors and Git clients show diffs visually, which many people find easier to read than the command-line format.

Staging changes to prepare for a commit

Before you commit, you must move your changes from the working directory into the staging area. You do this with git add. The command git add filename stages a single file, while git add . stages all modified files in the current folder and its subfolders. You can also stage specific lines within a file using git add -p, which prompts you to approve or skip each change one at a time.

Staging is a deliberate step, which means you can edit multiple files but commit them in separate, logical groups. For example, you might edit a configuration file and a feature file, but stage and commit them separately because they are unrelated changes. This keeps your commit history clean and makes it easier for others to understand what each commit does.

After staging, git status shows your changes under "Changes to be committed" instead of "Changes not staged for commit". This is your signal that the changes are ready to go into the next commit. If you stage something by mistake, git reset filename removes it from the staging area and puts it back in your working directory.

Discarding local working changes you do not want to keep

Sometimes you edit a file and then decide you do not want those changes. Git gives you two ways to throw them away. The command git checkout filename (in older versions of Git) or git restore filename (in newer versions) deletes all changes to that file and restores it to the last committed version. This is permanent — the edits are gone and cannot be recovered unless you committed them earlier.

If you have staged changes you want to discard, git reset filename removes them from the staging area first, then you can use git restore to delete them from your working directory. Alternatively, git reset --hard discards all staged and unstaged changes at once, reverting your entire working directory to the last commit. Use this with caution, because it wipes out everything you have edited since then.

Before you discard changes, run git diff to make sure you are throwing away what you think you are throwing away. It is easy to accidentally delete work you meant to keep, especially when using --hard flags.

The difference between unstaged and staged changes

The staging area exists to give you control. Without it, every file you edit would go into the next commit automatically, and you would have no way to separate related changes from unrelated ones. With the staging area, you can edit ten files, stage five of them, commit those five, then stage and commit the other five separately.

Unstaged changes are edits that Git sees but that you have not yet prepared for a commit. They sit in your working directory, visible to you but not yet part of the commit pipeline. Staged changes are edits you have explicitly marked with git add, and they will go into your next commit when you run git commit.

This two-step process — edit, then stage, then commit — is what makes Git powerful. You can review your changes with git diff before staging them, review what you have staged with git diff --staged before committing, and even undo a commit if you realize you made a mistake. Each step gives you a chance to catch errors before they become permanent history.

Common workflows with local working changes

A typical workflow looks like this: you open a file and make edits. You run git status to see what has changed. You run git diff to review the exact changes. You run git add to stage the files you want to commit. You run git diff --staged to review what is about to be committed. You run git commit -m "message" to save the changes to history. You repeat this cycle for the next set of changes.

Some people stage all their changes at once with git add . and then commit. Others stage files one at a time to keep commits small and focused. Neither approach is wrong — it depends on your project and your team's preferences. The important thing is that you understand what is staged and what is not before you commit.

If you are working on a feature that is not ready to commit yet, you can leave those changes unstaged and switch to a different branch with git checkout branchname. Git will warn you if switching branches would overwrite your unstaged changes, protecting you from accidentally losing work.

Frequently Asked Questions

What happens to my local working changes if I switch branches?

Git will not let you switch branches if doing so would overwrite your unstaged changes. It shows an error and tells you to either commit your changes, stage them, or discard them before switching. If your changes do not conflict with the other branch, Git may allow the switch and carry your changes along with you.

Can I see the history of changes I made to a file?

Yes, but only for changes that have been committed. The command git log filename shows every commit that touched that file, and git show commitid:filename shows what the file looked like at a specific commit. For unstaged changes in your working directory right now, git diff is your only option.

What if I stage changes by mistake?

Run git reset filename to remove the file from the staging area. The changes stay in your working directory — they just go back to being unstaged. You can then review them with git diff before staging them again if you want.

Do local working changes get saved automatically?

No. Your editor saves the file to disk when you press Ctrl+S or Cmd+S, but Git does not automatically record those changes. You must explicitly stage them with git add and then commit them with git commit for Git to save them to the repository.

Can I commit only part of a file?

Yes, using git add -p, which shows you each change in the file and asks whether you want to stage it. This is useful when you have made multiple unrelated edits to the same file and want to split them into separate commits.