How to remove the first commit in git?

后端 未结 9 1755
深忆病人
深忆病人 2020-12-07 07:20

I am curious about how to remove the first commit in git.

What is the revision before committing any thing? Does this revision have a name or tag?

9条回答
  •  猫巷女王i
    2020-12-07 07:49

    There is nothing before the first commit, as every commit is referring a parent commit. This makes the first commit special (an orphan commit), so there is no way to refer to a previous "state".

    So if you want to fix the commit, you can simply git commit --amend: this will modify the commit without creating another one.

    If you just want to start all over, delete the .git repository, and make another one with git init

提交回复
热议问题