[英]How to show a list of changed files since last commit if there was a merge?
I've been using the following command to see a list of files which changed since the previous commit, and for the most part it works. 我一直在使用以下命令来查看自上一次提交以来已更改的文件列表,并且在大多数情况下都可以使用。
git show --oneline --name-only HEAD | tail -n +2
However, consider this case. 但是,请考虑这种情况。
The repository is cloned in two places. 该存储库被克隆到两个地方。 Person A deletes a file from the repo called foo and pushes his changes up to the repo. 人员A从仓库中删除了一个名为foo的文件,并将其更改推送到仓库中。 After that person b deletes a file from the repo called bar and tries to push up his changes. 在那个人b之后,从仓库中删除了一个名为bar的文件,并尝试增加他的更改。 He is notified that he has to do a pull. 他被告知必须拉。 He does a pull and he has to merge. 他拉力,他必须合并。 After the merge, he pushes up his changes. 合并后,他推高了自己的更改。
The git show command above will not show any information about the files foo or bar. 上面的git show命令将不显示有关文件foo或bar的任何信息。 There is a similar command I can use, 我可以使用类似的命令
git show --oneline --stat | head -n -1 | tail -n +3 | awk '{print $1}'
But this will only list the file foo and not bar. 但这只会列出文件foo而不会列出bar。
What git command can I run to show that the file bar was changed? 我可以运行什么git命令来显示文件栏已更改?
git show object
displays the object such as a commit. git show object
显示对象,例如提交。 In the situation you explained, adding the two files and the merge happened in three separate commits. 在您说明的情况下,添加两个文件和合并是在三个单独的提交中进行的。 A simple way to see it is to use git log
and use the flag n
to limit the number of previous commits: 一种简单的查看方法是使用git log
并使用标志n
限制以前的提交次数:
git log --oneline --name-only -n 3
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.