How to use Git in Windows to recursively list the files committed, with the commit dates in descending order?

131 views Asked by At

So I am using Visual Studio 2022 Community and Git as the version control. The Git repository is stored locally on my computer. I have also downloaded and installed Git for Windows from the official Git website: https://git-scm.com/.

What I want to do with Git is list the files that have been committed to the local Git repository on my computer, sorted by the commit date in descending order, recursively (recursively meaning it will also include all the files in any subfolders as well). I can do that with Visual Source Safe by right clicking on a folder in Visual Source Safe, then then selecting "Show History...", and finally checking the "Recursive" checkbox and clicking "Ok":

enter image description here

If I do this with Visual Source Safe, Visual Source Safe will show all files that were checked in, including the files in all subfolders of the folder I am viewing the history of (hence the Recursive option), in a descending sort order of files checked in (ie. the latest checked in files will appear at the top). In a nutshell, I want to do with Git what I can already do with Visual Source Safe.

Unfortunately, the Git window in Visual Studio 2022 Community does not show this (it just shows the overall commit, but you have to click on each overall commit to see the files that were checked into Git for that commit, which isn't near as useful as what Visual Source Safe does). Since I also installed Git for Windows, I can run the Git command from the DOS prompt but I don't know the Git command and parameters that is capable of doing what Visual Source Safe can do. Any help would be appreciated, thanks!

1

There are 1 answers

0
Programmer Joe On BEST ANSWER

So with @jthill's help, I tested around with some of the options for the git command. The git command that does what I want is:

git log --name-status --oneline --pretty=format:"%x09%ad%x09%s"

The --online option is very useful, as it eliminates some information that I don't really care about and condenses the output to a format that is much easier to decipher information, just like Visual Source Safe. The git command above does not show the user who made the commit but I am the sole user using the local git repository on my computer so that information is not relevant to me. I believe you can modify the options behind the --pretty=format: if you want to also show the user who made the commit. I also checked tested the committing of a file in a subfolder and this command was able to show the commit of that file in the subfolder as well (I believe it showed this because the commit of the file in the subfolder was a part of the master branch, so I believe this git command shows all commits under the master branch).