What command lists all commits that are reachable from a given commit but exclude commits that are reachable from another given commit?
Posted by TinaGrn
Last Updated: June 07, 2024
To list all commits that are reachable from a given commit while excluding commits that are reachable from another given commit in Git, you can use the git log command with the appropriate syntax to specify the commits. Here is the command you would use:
git log <commit1> ^<commit2>
In this command: - <commit1> is the commit from which you want to see all reachable commits. - <commit2> is the commit whose reachable commits you want to exclude. For example, if you want to see all commits reachable from abc123 but exclude those reachable from def456, you would use:
git log abc123 ^def456
This lists all commits that are reachable from abc123 and not reachable from def456. You can also utilize the --oneline option for a more concise output:
git log --oneline <commit1> ^<commit2>
This would give a one-line summary of each commit.
Related Content