in Technology by

How do you find a list of files that have changed in a particular commit?

1 Answer

0 votes
by

For this answer instead of just telling the command, explain what exactly this command will do.

To get a list file that has changed in a particular commit use the below command:

git diff-tree -r {hash}

Given the commit hash, this will list all the files that were changed or added in that commit. The -r flag makes the command list individual files, rather than collapsing them into root directory names only.

You can also include the below-mentioned point, although it is totally optional but will help in impressing the interviewer.

The output will also include some extra information, which can be easily suppressed by including two flags:

git diff-tree --no-commit-id --name-only -r {hash}

Here –no-commit-id will suppress the commit hashes from appearing in the output, and –name-only will only print the file names, instead of their paths.

Related questions

0 votes
    How do you find a list of files that have been changed in a particular commit?...
asked Oct 4, 2020 in Technology by Editorial Staff
0 votes
    How will you find out what all files have been changed in a particular Git commit?...
asked Nov 4, 2020 in Technology by JackTerrance
0 votes
    I want to merge two branches that have been separated for a while and wanted to know which files have been modified ... I missed... Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    How to list all the files in a commit?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    In Git how do you revert a commit that has already been pushed and made public?...
asked Nov 2, 2020 in Technology by JackTerrance
0 votes
    How to display only the names of the changed files? A. git diff –name-only B. git log C. git status D. None of the options...
asked Dec 17, 2022 in Technology by JackTerrance
0 votes
    How can we stash only one of multiple changed files on my branch?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    I have made a commit and discarded it. I can still retrieve that commit using git reflog. A. True B. False...
asked Dec 24, 2022 in Education by JackTerrance
0 votes
    The _______________ policy, allows a transaction to commit even if it has modified some blocks that have ... Buffer Management in chapter Recovery System of Database Management...
asked Oct 10, 2021 in Education by JackTerrance
0 votes
    How do you add a particular state to the browsing history? (a) pushState() (b) replaceState() (c ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    How do you focus a particular part of the HTML page in JavaScript? (a) hover() (b) focus() (c ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
0 votes
    What do you mean by commit log in Cassandra?...
asked Apr 15, 2021 in Technology by JackTerrance
0 votes
    Which component do you need in order to prevent an unwanted commit in MySQL database? tMysqlRollback tMysqlCommit tMysqlLookupInput tMysqlRow...
asked Mar 25, 2021 in Technology by JackTerrance
0 votes
    I am a little bit puzzled on the question of whether to commit .tfstate files to Git or not. The Terraform ... if so, why? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    How do I list all files of a directory?...
asked Jan 9, 2021 in Technology by JackTerrance
...