is it possible to `git status` only modified files?

Go To StackoverFlow.com

129

Is it possible to git status and show only modified files?

The problem is i have too many staged files that i don't want to commit or gitignore at the moment and i can't scroll up. I have a scrollback limit set on Ubuntu.

2012-04-04 20:10
by chrisjlee
How do you have a scroll limit? By default, git status will invoke the pager - Lily Ballard 2012-04-04 20:16
Sorry scrollback limit is set to 512 lines on my machine. I guess i could change it; but would prefer a one line command to view just modified files in the status because GD/imagecache will generate even more files eventually - chrisjlee 2012-04-04 20:20
Right... my point is the pager doesn't use your terminal's scrollback - Lily Ballard 2012-04-04 20:26
Anything wrong with just grepping for whatever you find interesting? Use --short or --porcelain to get one-line versions of the status - torek 2012-04-04 20:26
One more point, based on the suggestion to use git ls-files -m: which modification(s) do you care about, staged, unstaged, or both - torek 2012-04-04 20:36


209

You can't do this with git status, but you could use git ls-files -m to show all modified files.

2012-04-04 20:26
by Lily Ballard
git status -uno works too - U007D 2013-05-03 21:05
Just so others know, this will only show files which have been modified without yet being staged - Gerry 2015-04-15 10:19
This shows modified files and deleted files - alex.jordan 2015-09-01 07:08
While this is the accepted answer, it has inaccurate information. You can "'git status' only modified files" with git status | grep modified just as user23186 indicates in their answer - K. Alan Bates 2016-01-18 17:00
@K.AlanBates My answer is correct. Your command is not running git status only on modified files, it's running git status on everything and then using a separate tool to throw away the unwanted info. Your answer also won't work if the user has the git config setting to always use short mode. A more accurate suggestion would have been git status -s | grep '^.M', but even that is just a poor way of accomplishing the same thing as git ls-files -m - Lily Ballard 2016-01-18 19:02
To be more specific, the mention of 'inaccurate information' is only to your first clause declaring that "you can't do this with git status." You totally can have git status return only modified files with grep. Of course your suggestion to use ls-files -m will function just fine; its just not as expressive, in my opinion - K. Alan Bates 2016-01-18 19:53
For me, git ls-files -m is not showing anything but git status | grep modified is working - Sandeepan Nath 2016-05-05 11:41
@KevinBallard Can you give all option of git ls-files - alhelal 2017-12-05 05:28
As others have pointed out, this only shows unstaged files. If you want to show both unstaged AND staged files, this is the best answer I've seen: https://stackoverflow.com/a/39994894/45258 - thdoan 2019-01-18 21:15
@thdoan There are a number of options for showing staged files, though this particular question seems to want to explicitly exclude staged files. git diff --name-only --diff-filter=M HEAD would show just modified files for both staged and unstaged, though you should check the docs on --diff-filter to see what other filter types you might want to add - Lily Ballard 2019-01-19 22:15


45

It looks like git status -uno will show you only files that git is tracking, without showing anything else in the directory. Not exactly what you asked for, but perhaps accomplishes the same thing (getting a readable-length list of files that git tracks).

2012-04-04 20:28
by TomNysetvold
git status -u no does not show (1) tracked files which are modified, nor (2) tracked files which are staged. I've verified this with git versions 1.8.5.2 and 1.9.4 - mxxk 2014-09-12 20:59
@TomNysetvold, you may actually mean git status -uno (http://stackoverflow.com/questions/7008546/command-git-status-u-no-filters-tracked-files-also - mxxk 2014-09-12 21:03


26

git status -s | awk '{if ($1 == "M") print $2}'
2012-11-20 18:15
by Carl Bäckström
Or awk '$1 == "M" { print $2 }'Calpau 2015-09-03 15:35
Not so good if path has space - C0DEF52 2018-05-10 11:57


23

For modified files:

git status | grep modified:
2014-12-04 12:48
by Lance Holland
So useful I've created an alias for this: git config --global alias.modified '!git status | grep modified:'Richard Parnaby-King 2016-01-12 11:23


7

git diff --name-only --diff-filter=M

2016-12-29 15:41
by ZeroGraviti
See addnl diff filter flag.... - ZeroGraviti 2016-12-30 18:29
I recommend those filters: git diff --cached --name-only --diff-filter=ACMR which does Added, Copied, Modified and Renamed files - qwertzguy 2018-01-30 01:17


6

git diff --name-only works too.

2016-02-21 13:37
by mpelzsherman


1

To list the modified files use:

git ls-files -m

If you want just the basename (no path) then you can pipe each result to the basename command using xargs, line by line:

git ls-files -m | xargs -L 1 basename
2017-11-09 23:33
by briggySmalls


0

I use git cola. Its a simple and elegant UI client that will show you the modified files and provide you with a diff like shot of the changes you made.

git cola provides you with a GUI where you can visualize which files you modified, which you staged, and even those you don't track. Your question was to use git status only I believe, but I thought git cola can help when that and other things as well. Check this web page from more info: git-cola.github.com/screenshots.html

2012-04-05 01:30
by n_x_l
Could you provide how that relates to my answer given i'm not familiar with this git cola. e.g. screenshots, or more detail - chrisjlee 2012-04-05 03:10
it that why is was downvoted? :) Anyway, git cola provides you with a GUI where you can visualize which files you modified, which you staged, and even those you don't track. Your question was to use git status only I believe, but I thought git cola can help when that and other things as well. Check this web page from more info: http://git-cola.github.com/screenshots.htm - n_x_l 2012-04-05 15:07
How to change cola's interface language - ziyuang 2014-10-13 14:21


0

If you want to list the modified files you could do this:

git log -n1 --oneline --name-status | grep '^M'

2016-11-29 22:44
by David Hernandez


0

To list all modified files use:

git show --stat --oneline HEAD
2018-07-27 04:08
by Fayaz


0

I was looking for the same info and found following gives modified files:

git status -uno
2018-12-09 06:42
by Tectrendz
Ads