Git 拉取更改日志

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6535150/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 05:38:21  来源:igfitidea点击:

Git pull change log

gitloggingcommitpull

提问by Gilles Maes

After pulling from a git server, I'm trying to get a list of all changed files. I don't need any specific parts of code, just a list of files (with some kind of indication as to wether it's been added, removed or changed).

从 git 服务器拉取后,我试图获取所有更改文件的列表。我不需要任何特定的代码部分,只需要一个文件列表(带有某种关于它是否被添加、删除或更改的指示)。

I first looked at using git log, but that appearantly only returns info from the last commit:

我首先查看了使用 git log,但这似乎只返回上次提交的信息:

git log --name-status --max-count=1 --pretty=format:""

git log --name-status --max-count=1 --pretty=format:""

Since this appearantly only gets the changes from the last commit in a pull, I'm trying to find a way to get all the changes (the pull almost always exists out of multiple commits).

由于这似乎仅从拉取中的最后一次提交中获取更改,因此我试图找到一种方法来获取所有更改(拉取几乎总是存在于多次提交之外)。

Is there any command for this? (I'm interacting with Git from PHP, btw)

有没有这方面的命令?(顺便说一句,我正在从 PHP 与 Git 交互)

回答by araqnid

After a pull, ORIG_HEADrefers to where you were before, and HEADrefers to where you are now. So ORIG_HEAD..means the changes pulled into the current branch. --max-count=1means just the last commit, not what you want, as you discovered.

拉后,ORIG_HEAD指的是你之前所在的位置,HEAD指的是你现在所在的位置。所以ORIG_HEAD..意味着将更改拉入当前分支。--max-count=1意味着只是最后一次提交,而不是您发现的您想要的。

You probably want something like git diff --name-status ORIG_HEAD..which will output a single-character status code and a filename for each file changed, aggregating all the commits together. If you want it broken down by each change, you need something like git log --oneline --name-status ORIG_HEAD..

您可能想要类似的东西git diff --name-status ORIG_HEAD..,它将为每个更改的文件输出一个单字符状态代码和一个文件名,将所有提交聚合在一起。如果您想按每次更改将其分解,则需要类似的内容git log --oneline --name-status ORIG_HEAD..

回答by mshiltonj

An alternative command is:

另一种命令是:

git pull --stat