How to remove the first commit in git?

后端 未结 9 1714
深忆病人
深忆病人 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条回答
  •  挽巷
    挽巷 (楼主)
    2020-12-07 07:30

    I was looking for a way to undo all git commits from a repo, like they never happened.

    Rebasing will work up to a point. However, the very first (chronologically the oldest git commit) is always going to be problematic, since it does not have a parent, so that will error out.

    None of these answers quite solved it for me. But after lots of searching and trial-and-error, I found this to work!

    git update-ref -d HEAD
    git push origin master -f
    

    Hope this helps you. Have a great day.

提交回复
热议问题