Through the command:
$git diff --name-status tag1 tag2 -- target-src
The output is like:
M src/config.h
M src/createTable.sql
A src/gameserver/BattleGround_10v10.h
M src/gameserver/CMakeLists.txt
M src/gameserver/achieve.cpp
M src/gameserver/achieve.h
A src/gameserver/action.cpp
A src/gameserver/action.h
A src/gameserver/activity.cpp
A src/gameserver/activity.h
M src/gameserver/admin.cpp
I got the files that has modified between the two tags. But I want the list order by committed time. How can I do that?
Thanks to ilius's answer , I added awk
for my request:
git diff --name-status tag1 tag2 | while read line ; do
status=${line:0:1}
path=${line:2}
date=$(git log -1 '--pretty=format:%ci' -- "$path")
echo "$date $status $path"
done | sort -r | awk '{print $4" "$5}'
But I think it is too complicated. Can it be simpler?
You can try the same thing, but with git log
:
git log --name-status tag1 tag2 -- target-src
That way, the files are sorted in the order the commits were made. Also git log
has various sorting options you can try out.
Using mart1n's idea ,
git log --name-status '--pretty=format:' tag1 tag2 -- target-src | grep -vxh '\s*'
gives a clean output.
Also try this script:
git diff --name-status tag1 tag2 | while read line ; do
status=${line:0:1}
path=${line:2}
date=$(git log -1 '--pretty=format:%ci' -- "$path")
echo "$date $status $path"
done | sort -r
You can remove the dates (used for sorting) later, I think dates are useful though.
You can also remove -r
option from sort
if you want the older changed files to be on top.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.