For full path names of changed files:
git log --name-only
For full path names and status of changed files:
git log --name-status
For abbreviated pathnames and a diffstat of changed files:
git log --stat
There are a lot more options. Check out the documentation.
Answer from Lara Bailey on Stack OverflowFor full path names of changed files:
git log --name-only
For full path names and status of changed files:
git log --name-status
For abbreviated pathnames and a diffstat of changed files:
git log --stat
There are a lot more options. Check out the documentation.
NOTE: git whatchanged is deprecated, use git log instead
New users are encouraged to use git-log[1] instead. The
whatchangedcommand is essentially the same as git-log[1] but defaults to show the raw format diff output and to skip merges.The command is kept primarily for historical reasons; fingers of many people who learned Git long before
git logwas invented by reading Linux kernel mailing list are trained to type it.
You can use the command git whatchanged --stat to get a list of files that changed in each commit (along with the commit message).
References
- https://git-scm.com/docs/git-whatchanged
Videos
This lets Git generate the patches for each log entry:
git log -p -- <filename>
-p in git generates patch text
See git help log for more options — it can actually do a lot of nice things. :)
To get just the diff for a specific commit, use
git show <revision> -- <filename>
or specify any other revision by identifier.
To browse the changes visually:
gitk -- <filename>
To see changes visually without leaving the console, run:
git blame-log <filename>
However, first ensure blame-log command exists, by at least once running:
# Virables: raw=unchanged-line, c=clean, B=Buffer,
git config --global alias.blame-log "! cd -- \"\${GIT_PREFIX:-.}\" && \
( if git grep -qI \".\" \"\$1\"; then \
git log --oneline --color=always -L 1,\${2:-}:\"\$1\" | awk ' \
{ s=\$0; gsub(/\\033\\[[0-9;]*[mK]/, \"\", s) } \
s~/^(diff|---|\\+\\+\+)/{next} \
s~/^@@/{l=1;p=9;bi=0;cm=0;cp=0;next} s!~/^[-+ ]/{print;l=1;p=9;bi=0;cm=0;cp=0;next} \
/^ /{ cm=0;cp=0; if(p<3){print;p++}else{b[bi%3]=\$0; bl[bi%3]=l; bi++} l++; next } \
{ if(p>=3){ n=(bi<3?bi:3); st=(bi<3?0:bi%3); print \"\\033[36mLine \"(n?bl[st]:l)\":\\033[m\"; for(k=0;k<n;k++)print b[(st+k)%3] } \
p=0; if(s~/^-/){cm++;if(cm<=12)print;else if(cm==13)print\"...\"} else{cp++;if(cp<=12)print;else if(cp==13)print\"...\";l++} }'; \
else \
echo \"Detected binary file, hence not showing lines-changed.\"
git log --oneline --color=always \"\$1\";
fi ) | less -RX #"
Note that
blame-logis intentionally limited to showing few lines per change-range, for example, to skippackage-lock.jsonfaster.
For a graphical view, use gitk:
gitk [filename]
To follow the file across file renames:
gitk --follow [filename]
For a console view, maybe because you SSH into a head-less server, run:
git blame-log <filename>
However, first ensure blame-log command exists, by at least once running:
# Virables: raw=unchanged-line, c=clean, B=Buffer,
git config --global alias.blame-log "! cd -- \"\${GIT_PREFIX:-.}\" && \
( if git grep -qI \".\" \"\$1\"; then \
git log --oneline --color=always -L 1,\${2:-}:\"\$1\" | awk ' \
{ s=\$0; gsub(/\\033\\[[0-9;]*[mK]/, \"\", s) } \
s~/^(diff|---|\\+\\+\+)/{next} \
s~/^@@/{l=1;p=9;bi=0;cm=0;cp=0;next} s!~/^[-+ ]/{print;l=1;p=9;bi=0;cm=0;cp=0;next} \
/^ /{ cm=0;cp=0; if(p<3){print;p++}else{b[bi%3]=\$0; bl[bi%3]=l; bi++} l++; next } \
{ if(p>=3){ n=(bi<3?bi:3); st=(bi<3?0:bi%3); print \"\\033[36mLine \"(n?bl[st]:l)\":\\033[m\"; for(k=0;k<n;k++)print b[(st+k)%3] } \
p=0; if(s~/^-/){cm++;if(cm<=12)print;else if(cm==13)print\"...\"} else{cp++;if(cp<=12)print;else if(cp==13)print\"...\";l++} }'; \
else \
echo \"Detected binary file, hence not showing lines-changed.\"
git log --oneline --color=always \"\$1\";
fi ) | less -RX #"
Note that
blame-logis intentionally limited to showing few lines per change-range, for example, to skippackage-lock.jsonfaster.
I would recommend using a different format than the default. My usual choice is a summary with the graph, but a one-line summary alone usually does the trick.
Option 1: One-line summary with a graph
git log --pretty=format:'%h : %s' --graph > log.log
Results in:
* 2d3acf9 : ignore errors from SIGCHLD on trap
* 5e3ee11 : Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 : Added a method for getting the current branch.
* | 30e367c : timeout code and tests
* | 5a09431 : add timeout protection to grit
* | e1193f8 : support for heads with slashes in them
|/
* d6016bc : require time for xmlschema
Option 2: One-line summary without a graph
git log --pretty=format:'%h was %an, %ar, message: %s' > log.log
Results in:
a6b444f was Scott Chacon, 5 days ago, message: dammit, this is the second time this has re
49d77f7 was Scott Chacon, 8 days ago, message: modified index to create refs/heads if it i
9764edd was Hans Engel, 11 days ago, message: Add diff-lcs dependency
e1ba1e3 was Hans Engel, 11 days ago, message: Add dependency for Open4
0f87b4d was Scott Chacon, 12 days ago, message: merged recent changes
You can find more formatting options in the documentation here.
Try this line
git log > log.txt