What command lists all commits that are reachable from a set of commits, but exclude any reachable from another set?
Posted by IreneSm
Last Updated: June 24, 2024
To list all commits that are reachable from a set of commits but exclude any reachable from another set in Git, you can use the git log command with specific options. The general syntax for this command is:
git log <commit-set> --not <exclude-set>
Here's a breakdown of how to use it: - <commit-set>: This is the set of commits you are interested in. - --not: This option tells Git to exclude commits that are reachable from the next set. - <exclude-set>: This is the set of commits that you want to exclude from the results.
Example
Suppose you want to list all commits reachable from master but exclude those reachable from develop. You would run:
git log master --not develop
If you want to use more than one commit or branch, you can specify multiple commits or branches like so:
git log master --not develop --not feature-branch
This command will display all commits reachable from master but not from develop or feature-branch. You can also include additional options to format the output, such as --oneline for a more concise view or --graph to visualize the branching structure. Here's an example with formatting:
git log master --not develop --oneline --graph
This will give you a clearer picture of the commits in a graphical format.
Related Content