marcushwz
marcushwz

Reputation: 21

How to achieve "first-parent" merge in git?

I am curious about how merging is done to the git repository on GitHub. When I visit the commits page, I only see the "first-parent" commit as you would see using git log --first-parent.

git's repo commit page git log --oneline --graph git log enter image description here

Where as on my own repo, which I perform the merge with git merge --log --no-ff branch_name always show both the merge commit and the commit itself.

my repo commits page my repo git log

I can't seem to find any options on git merge that will allow that. Basically, I am looking for ways where when I call git merge it will only add the merge commit, instead of adding both the merge commit and the commit itself.

Upvotes: 2

Views: 446

Answers (1)

matt
matt

Reputation: 534977

First, what GitHub shows is only an interface, and it is not Git's interface. So please try this: git fetch and now just say git log --oneline --graph --decorate and see what actually happened.

If now you see that there really is only one parent of this commit, that shows that this was never a merge commit to begin with: GitHub lets you merge pull requests using Squash or Rebase instead of a true merge, so there is indeed only one parent.

Upvotes: 1

Related Questions