git删除所有Commits提交历史记录,变为全新仓库

2018-01-29  本文已影响0人  貳條

个人感觉一般两个情况下,会想有这个需要:

1. Checkout

新建一个branch

git checkout --orphan latest_branch

2. Add all the files

git add -A

3. Commit the changes

git commit -am "commit message"

4. Delete the branch

git branch -D master

5. Rename the current branch to master

git branch -m master

6. 连接远程库

把下面的Hzfans替换成你自己的GitHub账户名,Hzfans.github.io替换为你自己的项目名称。
连接后,远程库的名字就是origin,这是Git默认的叫法,也可以改成别的,但是origin这个名字一看就知道是远程库。这一步非必要,如果你之前已经连接了的话,以防万一。

git remote add origin git@github.com:Hzfans/Hzfans.github.io.git

7. Finally, force update your repository

git push -f origin master

YUHONGJUN.GITHUB.IO

上一篇下一篇

猜你喜欢

热点阅读