How can I see all the files that have been changed / added / removed in the received last click?

The command git show --pretty="format:" --name-status bd61ad98

will show a list of all files changed / added / removed in the last command, where bd61ad98

is the commit ID. The result looks like this:

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

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


How about a command that displays the same information but for all commits from the last push? For example, if a file was deleted ( D

), then re-added ( A

), and then modified ( M

), the ideal status would be M

to change. In other words, the net effect is that the file has changed.

Is there such a command? Even if the team had to display duplicate statuses for files, everything will be fine. I could write a script that can detect the network effect.

Maybe there is a way to compare diffs and list files modified / removed / added?

The reason I need a file like this is because I am creating a script that will update another location using FTP based on this information.


source to share

2 answers

Do you really want git diff-tree

; see my other answer to your other question. :-)

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 the actual tree ID, but then you have to give it both tree IDs, since it won't be able to find the parent, for example:

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


(obviously the id will change).

If you have a branch name that refers to "what we pushed last", for example a branch THEYHAVE

, and you want to push them what's on the branch TESTED

, you can do:

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


and use different letter codes and meanings in $nhash

etc. to fetch files ("git cat-file -p $ nhash" you will get the contents of the file even in the repository --bare


(You can simplify this with a help --name-status

for your case, perhaps.)

Once you have all the FTP-ed where it should go, you can use git update-ref

to move the branch tag THEYHAVE to any branch named TESTED (maybe it is recommended to use it git rev-parse

once to grab the ID of that branch "up" if it moves, while you do all this work).



I don't know the exact format diff

, but here's what you can do in your script:

  • git fetch

    Note. Do not pull, but pull out.
  • Make diff

    between <branch>

    and <remote>/<branch>

    in whatever format you like and save the results or take action as needed.
  • Combine <remote>/<branch>


This way you can perform actions on individual push




All Articles