is it possible to `git status` only modified files?
GitUbuntuGit StatusGit Problem Overview
Is it possible to have git status
only show the modified files due, in my case, to having too many staged files?
Git Solutions
Solution 1 - Git
You can't do this with git status
, but you could use git ls-files -m
to show all modified files.
Solution 2 - Git
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).
Solution 3 - Git
For modified files:
git status | grep modified:
Solution 4 - Git
git status -s | awk '{if ($1 == "M") print $2}'
Solution 5 - Git
git diff --name-only --diff-filter=M
Solution 6 - Git
git diff --name-only
works too.
Solution 7 - Git
You can use
$ git status -uno
to list only modified files.
Solution 8 - Git
I was looking for the same info and found following gives modified files:
git status -uno
Solution 9 - Git
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
Solution 10 - Git
>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.
While this may not directly answer the question of listing only modified files, it may help limit the number of files that are listed.
You can pass a path to git status
to limit the output to a specific folder in the repo.
For example:
git status app
git status spec
git status src/components
Solution 11 - Git
I use this command :
$ git status -sb -uno | grep -v "^\sD\s"
And the output looks like this :
## master...origin/master
M GNUmakefile
M include/mp4v2/project.h
Solution 12 - Git
Update
open the .gitconfig
[user]
name = ...
email = ...
[alias]
# 👇 add below code
mySt = "!f() {\
inputType=${1:-" "};\
git status -s | grep "\\ $inputType" |\
sed -e 's/ / /' ;\
}; f"
explain: https://stackoverflow.com/a/62772985/9935654
usage
> git mySt M
: show modified:
>
> git mySt M *.md
: Show all *.md, which was modified.
>
> git mySt D
: deleted:
>
> git mySt
: same as the git status -s
>
OS: windows
The following command will display all lines containing "modified:", "renamed:" or "new file:"
git status | findstr "modified: renamed: new file:"
If you want to specified file type: (for example *.py
*.ini
)
git status *.py *.ini | findstr "modified: renamed: new file:"
If you think it’s too much trouble typing so much:
-
create a batch file (for example:
st.bat
) -
write contents as following:
@echo off :: st.bat (this line doesn't necessarily. ( just let you know the scripts name.)) git status %~1 | findstr "modified: renamed: new file:"
-
add environment path which contains your batch file. (
st.bat
) -
usage
st.bat "*.py *.ini"
(note: if type > 1 then must add the semicolon)
OS: LINUX
as @Lance says you can try
git status | grep modified:
Solution 13 - Git
One alternative is to have the results on a single line via -s
which can limit what is being shown.
git status -s
Shown under windows Terminal with Powerline/Posh git.
This command is so handy in that I added it as an alias used as git stati
[alias]
stati = !git status -s
Solution 14 - Git
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
Solution 15 - Git
If you want to list the modified files, you could do this:
git log -n1 --oneline --name-status | grep '^M'
Solution 16 - Git
To list all modified files use:
git show --stat --oneline HEAD
Solution 17 - Git
All great answers; just FEI, "git checkout