document updated 12 years ago, on Jun 26, 2012
Ways to see what a command would do, without actually carrying out the action.
.gitignore
To list the files that don't match .gitignore:
- git ls-files -ocm --exclude-standard
- git status -u
To list the files that do match .gitignore:
- (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | sort | uniq
- (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | perl -nle '$seen{$_}++||next;if(-d){system"find",$_,"-type","f"}else{print}'
- git clean -ndX
To list both together:
(git ls-files -ocm --exclude-standard | perl -ple 's/^/+ /'; (git ls-files -oi --exclude-standard; git ls-files -oi --exclude-standard --directory) | perl -nle '$seen{$_}++||next;if(-d){system"find",$_,"-type","f"}else{print}' | perl -ple 's/^/- /') | sort
built-in
Commands that have a good option built-in:
- git add -n
- git commit --dry-run