Git log to get commits only for a specific branch

后端 未结 12 1711
挽巷
挽巷 2020-11-29 15:13

I want to list all commits that are only part of a specific branch.

With the following, it lists all the commits from the branch, but also from the parent (master)

12条回答
  •  旧时难觅i
    2020-11-29 15:43

    BUT I would like to avoid the need of knowing the other branches names.

    I don't think this is possible: a branch in Git is always based on another one or at least on another commit, as explained in "git diff doesn't show enough":

    enter image description here

    You need a reference point for your log to show the right commits.

    As mentioned in "GIT - Where did I branch from?":

    branches are simply pointers to certain commits in a DAG

    So even if git log master..mybranch is one answer, it would still show too many commits, if mybranch is based on myotherbranch, itself based on master.

    In order to find that reference (the origin of your branch), you can only parse commits and see in which branch they are, as seen in:

    • "Git: Finding what branch a commit came from".
    • "How can I see what branch another branch was forked from?"

提交回复
热议问题