1

I want to merge two commits into one. I have seen this article and tried to use squash with rebase but it was not fit me because of I have 2 commits at all and want to merge these 2 commits into 1. git log --pretty=oneline give me:

b776cabedd911ba0030537030496ca24102ff7f1 Initial commit.
7b5fb155372b129b38be0c54d184427632d949d4 Second commit.

Can someone help?

Community
  • 1
  • 1
fortegente
  • 1,361
  • 2
  • 11
  • 22

1 Answers1

1

If you have ONLY 2 commit, they can't be merged in common way, because git rebase -i then squash need a commit before these 2 commit, which doesn't exists.

So, as you can see on github or other public git repostory, the common way of the first commit is an alomost empty commit, with a empty .gitignore file. This will avoid situation you meet now.

If you really need to merge these 2 commit, here is my answer:

  1. Export you 2 commit with git format-patch -2
  2. Re-create your local git repo using git init
  3. Apply 2 patch file export in (1) by git apply 0001* git apply 0002*
  4. Commit
Fwolf
  • 671
  • 4
  • 8