How to remove the first commit in git?

后端 未结 9 1766
深忆病人
深忆病人 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:40

    # Check out to a temporary branch:
    git checkout --orphan TEMP_BRANCH
    
    # Add all the files:
    git add -A
    
    # Commit the changes:
    git commit -am "Initial commit"
    
    # Delete the old branch:
    git branch -D master
    
    # Rename the temporary branch to master:
    git branch -m master
    
    # Finally, force update to our repository:
    git push -f origin master
    

提交回复
热议问题