git - list of all changed but not deleted files in a commit
git
Solution
Try using this command:
git show --diff-filter=AM --pretty="format:" --name-only #{commitId}
It is what you mentioned in your original problem with a `--diff-filter` flag added to restrict to only files which were added (`A`) or modified (`M`). For a complete list of the types of files to which you can restrict, have a look at the documentation for git show.
As @MauricioTrajano mentioned in his answer, you don't need to reset to a commit to investigate it using `git show`. All you need to know is the SHA-1 hash of the commit, which you can find by simply using `git log` on the branch in question.
Problem
I am investigating git repositories. I want to get the list of changed files in each commit. So, what I did is I visited each commit through the command ``` git reset --hard <commitId> ``` Then, I used ``` git show --pretty="format:" --name-only #{commitId} ``` The problem with this one is that it gives the deleted files in that commitId which I don't want. I tried also: ``` git ls-files ``` it doesn't return deleted files, however, it returns a list of all existing files that are new or were created in previous commit. Example: ``` >commit 1 add "file1" add "file2" >commit 2 change "file1" >commit 3 add "file3" delete "file2" ``` so in this case, I will visit each commit. And, if I am in commit 1, I want to get a list of "file1" and "file2". If I am in commit 2, I will get "file1", and "file3" if I am in commit 3. Any thought?