Merge two commits into one and push to remote repo

This question already has an answer here:

  • Combine the first two commits of a Git repository? 7 answers
  • Edit the root commit in Git? 5 answers

  • 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:

  • Export you 2 commit with git format-patch -2
  • Re-create your local git repo using git init
  • Apply 2 patch file export in (1) by git apply 0001* git apply 0002*
  • Commit
  • 链接地址: http://www.djcxy.com/p/23464.html

    上一篇: 限制Q在Node js中承诺并发

    下一篇: 将两个提交合并为一个,并推送到远程回购