0

What I want is to get a list of files that where deleted since the last commit to git.

Currently I'm getting a list of all the changed files since the last commit which I then use to upload those files to my server through jenkins. However I couldn't find anything on getting a list of deleted files since the last commit.

So what I'm trying to achieve is getting a list of the removed files and remove these from the server through jenkins.

I hope it's clear what I'm trying to achieve

2 Answers 2

2

Here you are: git diff --diff-filter=D --name-only HEAD

Sign up to request clarification or add additional context in comments.

7 Comments

an additional question to this filter. Is it also possible to select EVERYTHING BUT the removed files?
Sure: git diff --diff-filter=ACMRTUXB --name-only HEAD. For the meaning of each filter character, read git help diff and search for diff-filter. Ah, or even better, just seen it myself: git diff --diff-filter=d --name-only HEAD. Lowercase means exclude uppercase means include.
I found the page indeed but I just entered the values wrong apparantly haha. However I'm having a problem. I'm comparing 2 commits with eachother to put the files that changed in a zip and these are then transfered to my ftp. However when I delete files it will try to add those files to a zip (which causes an error obviously). But when I make my command like this: git archive --output=publish/update.zip HEAD $(git diff --name-only $PREVIOUS $CURRENT) it will just grab ALL the files that are present. Any clue what I should change?
What's the matter with adding --diff-filter=d? Works fine for me, as long as there are not too many changed lines so that the command line is too long as there is a maximum limit for command length.
when I add --diff-filter=d the same thing happens it just seems to grab all the files that are in the git. I think it doesn't look at the differences between the 2 commits that are specified. So what happens is it will look at everything that ever changed and add it to the zip. This only happens with the filter in there. $PREVIOUS and CURRENT are the commit id's that I'm comparing against eachother
|
1

Try to use

git diff --diff-filter=D --summary

it will give you list of deleted files one per line like following:

delete mode 100644 path/deleted.file

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.