How to list only the file names that changed betwe

2020-01-22 13:23发布

I have a bunch of commits in the repo. I want to see a list of files changed between two commits - from SHA1 to SHA2.

What command should I use?

13条回答
祖国的老花朵
2楼-- · 2020-01-22 13:24

To supplement @artfulrobot's answer, if you want to show changed files between two branches:

git diff --name-status mybranch..myotherbranch

Be careful on precedence. If you place the newer branch first then it would show files as deleted rather than added.

Adding a grep can refine things further:

git diff --name-status mybranch..myotherbranch | grep "A\t"

That will then show only files added in myotherbranch.

查看更多
Root(大扎)
3楼-- · 2020-01-22 13:27

As artfulrobot said in his answer:

git diff --name-status [SHA1 [SHA2]]

My example:

git diff --name-status 78a09k12067c24d8f117886c4723ccf111af4997 
4b95d595812211553070046bf2ebd807c0862cca
M       views/layouts/default.ctp
M       webroot/css/theme.css
A       webroot/img/theme/logo.png
查看更多
Lonely孤独者°
4楼-- · 2020-01-22 13:29

Add below alias to your ~/.bash_profile, then run, source ~/.bash_profile; now anytime you need to see the updated files in the last commit, run, showfiles from your git repository.

alias showfiles='git show --pretty="format:" --name-only'
查看更多
5楼-- · 2020-01-22 13:29

The following works well for me:

$ git show --name-only --format=tformat: SHA1..SHA2

It can also be used with a single commit:

git show --name-only --format=tformat: SHA1

which is handy for use in Jenkins where you are provided with a List of changeSet SHA's, and want to iterate over them to see which files have been changed.

This is similar to a couple of the answers above, but using tformat: rather than format: removes the separator space between commits.

查看更多
迷人小祖宗
6楼-- · 2020-01-22 13:35

Use git log --pretty=oneline >C:\filename.log

which will log only a oneline (--pretty=oneline) thats the name of the changed file. Also will log all the details to your output file.

查看更多
Juvenile、少年°
7楼-- · 2020-01-22 13:39

Based on git diff --name-status I wrote the git-diffview git extension that renders a hierarchical tree view of what changed between two paths.

查看更多
登录 后发表回答