1

删除所有git commit

 2 years ago
source link: https://blog.leixin.wang/50675bd.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

删除所有git commit

发表于 2019-03-26

| 0

| 浏览 1次

字数统计: 140

|

阅读时长 ≈ 1

记录一下,删除所有git commit的方法,但不改变原有代码的方式

# 1. 将当前分支备份
git checkout --orphan backup
# 2. 添加文件到备份分支
git add -A
# 3. 提交
git commit -am "commit message"
# 4. 删除分支
git branch -D master
# 5. 把当前分支重命名为备份的分支
git branch -m master
# 6. 强制更新代码到远程分支
git push -f origin master

不要问我为什么会有这篇文章,说多了都是泪,我的历史提交啊。。。


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK