Home » Git » How to see a list of staged file changes in Git

How to see a list of staged file changes in Git

By Emily

When you’ve made a lot of changes to a lot of files in your git repo, and you have ‘staged your changes’, you may very well want to view the list of staged files before you commit those changes to the repo. In other words git list staged files. You might not want to see untracked files in the list, just the ones that have been staged already. In this post I’ll explain how to use git commands to do this, to ‘git see staged changes’ in other words.

But what are staged changes in git?

Before we go any further it’s worth taking a minute to understand what ‘staging changes’ means and why we do it. For a while I always felt like it was a bit of a pointless step. I always staged my changes and then committed them… so why did I need to stage them in the first place? Thing of staging files as preparing which files you want to be associated with a specific commit message.

I began to understand staging when I worked on a big project with a big team where each piece of work that went into the repository needed to be identifiable against a reference. I would make changes to some files locally and then I’d need to push them up the remote repo in two different commits. So how could I determine which file went in which commit? By staging them using the git add command (official documentation here). And that’s when the staging process made sense to me. It’s also when I realised I needed to be able to ‘git list staged files’ so I could see which files I had already assigned to the next commit.

List staged files in git

To view a list of staged changes in git, type this command:

git diff --staged

This lists the files which have been staged, and shows the changes which have been made. If you have one file staged then it’s useful, if you have staged a LOT of files then it isn’t so clear.

See detailed list of staged changes

To view a clearer list of staged changes in git, use:

git diff --name-only --staged

Using the --name-only flag shows only the name of the changed files.

Also remember that you can use git status to see a summary of the current state of your repo, including seeing untracked files, files which have changed but are not staged, and files which are staged for commit.

See the changes you’ve changed but not staged

To see what you have changed but not yet staged:

git diff

To see the changes you’ve staged in git (and therefore what will go in your next commit):

git diff --staged