If I have several commits waiting to be pushed to a remote, how can I see a list of all of the files from all outgoing commits at once.
In Visual Studio, I can view the files in each commit individually but can't seem to figure out how I can see a union of all of the outgoing files at once.
Is this possible in Visual Studio? What about git?
CodePudding user response:
In Visual Studio, in the graphical "View History" view, you can select a commit (with left click), then press control while left-clicking on any other commit, and then right click on either of the two selected commits and select "Compare Commits...". This will show a view that lists all of the files, and you can select each file individually to see the changes in that file between the 2 commits.
From the command line:
git diff commit1 commit2 # show all changes between 2 commits
git diff commit1 commit2 --name-only # list only the filenames changed between 2 commits
Note, when comparing commits (with VS or diff) you want to compare the parent of the oldest commit with the newest commit, so that you can see all the changes across all commits. For example, if you had just 1 commit, you would compare that commit with its parent, which by the way is exactly what VS will show you if you view the changes of a single commit.
CodePudding user response:
You can use this command to list filenames from all outgoing commits.
git diff --name-only $(git merge-base <branch> origin/<remote_branch>) <branch>
It uses git merge-base
to compute the common parent commit for local and remote branch. Then it compares this common parent with local branch.