如何查看上次收到的推送中修改/添加/删除的所有文件? [英] How can I see all the files that were modified/added/removed in the last push received?

查看:155
本文介绍了如何查看上次收到的推送中修改/添加/删除的所有文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

命令 git show --pretty =format:--name-status bd61ad98 将会显示最后修改/添加/删除的所有文件的列表提交其中 bd61ad98 是提交ID。输出看起来像这样:

$ p $ [trusktr @ rocketship express.git] $ git show --pretty =format: - -name-status bd61ad98

test.txt
D test3.txt
M wp-atom.php

对于显示相同信息的命令,但对于上次推送的所有提交,该怎么办?例如,如果文件被删除( D ),然后重新添加( A ),然后修改( M ),对于修改,理想状态将为 M 。换句话说,最终效果是文件被修改了。



有没有这样的命令?即使命令列出了文件的重复状态,也没关系。我可以编写一个脚本来确定净效应。



也许有一种方法可以比较差异并输出修改/删除/添加的文件列表?



我需要这样一个文件的原因是我正在制作一个脚本,它会根据这个信息使用FTP更新另一个位置。

解决方案

您真的想要 git diff-tree ;请参阅我对你的其他问题的其他答案。 : - )



编辑详情:

  git diff-tree -r [其他选项] commit1 [commit2] 

会为您提供更改(格式为git-diff-tree)在commit1和(我认为)它的直接父母(如果commit2被省略)之间,或者在commit1和commit2之间做出的。



它是一个实际的树ID,但你必须给它两个树ID,因为它无法找到父项,例如:

  git diff-tree -r 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f 
error:Object 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f是一棵树,不是提交





如果您有一个分支名称引用我们最后发送的内容,例如分支 THEYHAVE ,并且你想发送它们到分支 TESTED 上的内容,你可以这样做:

  git diff-tree -r THEYHAVE TESTED | 
while read omode nmode ohash nhash letter pathname;做
...
完成

并使用各种字母代码和值在 $ nhash 等文件中提取文件(git cat-file -p $ nhash会在文件的内容中找到 - bare repo)。



(你可以用 - name-status

一旦你将所有东西都FTP到应该去的地方,然后你可以使用 git update -ref 将分支标签THEYHAVE移动到任何名为TESTED名称的分支(最好使用 git rev-parse >如果在你完成所有这些工作的同时移动,那么可以在前面获取该分支的ID。)


The command git show --pretty="format:" --name-status bd61ad98 will show a list of all the files modified/added/deleted in the last commit where bd61ad98 is the commit ID. The output looks like this:

[trusktr@rocketship express.git]$ git show --pretty="format:" --name-status bd61ad98

A       test.txt
D       test3.txt
M       wp-atom.php

What about a command that shows the same information but for all the commits from the last push? FOr example, if a file was deleted (D), then re-added (A), then modified (M), the ideal status would be M for modified. In other words, the net effect is that the file was modified.

Is there any such command? Even if the command were to list the duplicate statuses for files, that'd be fine. I could write a script that can determine the net effect.

Perhaps there's a way to compare diffs and output a list of files modified/deleted/added?

The reason I need such a file is that I'm making a script that will update another location using FTP based on this info.

解决方案

You really want git diff-tree; see my other answer to your other question, too. :-)

Edit for details:

git diff-tree -r [other options] commit1 [commit2]

will give you the changes (in the formats documented for git-diff-tree) made either between commit1 and (I think) its immediate parent (if commit2 is omitted), or between commit1 and commit2.

You can also give it an actual tree-ID but then you must give it both tree IDs since it will not be able to find the parent, e.g.:

git diff-tree -r 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f
error: Object 69d8f48dd3e69f228b9a727cc69f8fbaf4534b4f is a tree, not a commit

(obviously the ID will vary).

If you have a branch name that refers to "what we last sent out", e.g., branch THEYHAVE, and you want to send them what's on branch TESTED, you could do:

git diff-tree -r THEYHAVE TESTED |
    while read omode nmode ohash nhash letter pathname; do
        ...
    done

and use the various letter codes and values in $nhash and so on to extract the files ("git cat-file -p $nhash" will get you the contents of the file even in a --bare repo).

(You can simplify this with --name-status for your case, probably.)

Once you have everything FTP-ed to where it should go, you can then use git update-ref to move the branch-label THEYHAVE to whatever the branch named TESTED names (it might be a good idea to use git rev-parse once to grab the ID of that branch "up front", in case it moves while you're doing all this work).

这篇关于如何查看上次收到的推送中修改/添加/删除的所有文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆