How can I get a summary similar to git add –interactive?
I am looking for a Bash command (or sequence of commands) that prints a summary of what files are changed in a Git working copy. The summary should include the number of insertions and deletions in each file, and maybe whether they are staged.
git add --interactive (which is synonymous with
git add -i) gives exactly the summary I want (plus other stuff). The problem is that it doesn’t just print and exit, it starts up a whole non-Bash shell. Here is the part of
git add -i that I like:
- Action hook for OpenShift Node.js app does not execute, despite setting execute permission
- docker-compose, export environnement variables are not working in Jenkins
- Can make shell run interactively along with --command option
- Using the execute shell command in Jenkins to run git commands on a Windows machine
- How to group output in command shell
- unable to look up https fatal error when push to git repository
bash$ git add -i staged unstaged path 1: unchanged +3/-0 trunk/src/analyzer.c 2: unchanged +5/-13 trunk/src/converter.c
That’s a great summary. Unfortunately, after it prints, you are not back in Bash. To get back to Bash, you need to type
q and then enter, to quit. I really want it to just print the summary and then stop.
Here is what I have tried:
Type the following in the Bash terminal:
git add -i; q. This doesn’t work, it still needs you to press
qmanually, and then it gives an error because of the second
Put the following in a script
gitsummary.shand then run it:
git add -i, with or without
; qat the end. Same problem.
How can I get this summary in a totally non-interactive way? I can think of two possible solutions:
Use a Bash trick that waits a fraction of a second and then simulates a key press.
Use a different Git command that prints the same information but doesn’t start a strange little shell.
My main setup: Mac OS X 10.9 and Terminal (running /bin/bash).
My secondary setup: Windows 7 or 8 and Cygwin running Bash.
One Solution collect form web for “How can I get a summary similar to git add –interactive?”
Either of these should give you what you want:
git diff --numstat git diff --stat