当前位置:   article > 正文

[原创]删除github提交记录_删除github历史提交记录

删除github历史提交记录

在向github资料的时候,不小心将敏感信息提交进去了,怎么办?

这时候,git命令,就该上场了。

首先进入命令行,切换到项目的根目录之下(需要看到.git文件夹才对)

D:\赵庆明课件\WxOAuthManager>dir/a
 驱动器 D 中的卷是 新加卷
 卷的序列号是 BCAB-5003

 D:\赵庆明课件\WxOAuthManager 的目录

2022/08/07  08:10    <DIR>          .
2022/08/06  14:46    <DIR>          ..
2022/08/28  15:34    <DIR>          .git
2022/08/06  14:48             6,352 .gitignore
2022/08/28  15:25    <DIR>          .vs
2022/08/06  14:48             1,087 LICENSE
2022/08/06  14:48               107 README.md
2022/08/28  14:53    <DIR>          配套代码
               3 个文件          7,546 字节
               5 个目录 85,042,708,480 可用字节
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16

然后执行如下命令(如果git命令不可用,则请请到https://git-scm.com/download/win下载,安装):

#切换到新分支
	git checkout --orphan latest_branch
	#Switched to a new branch 'latest_branch'

#添加所有文件
 	git add -A

#提交更改
 	git commit -am "Reinitialize"
 	#[latest_branch (root-commit) edbcfa9] Reinitialize
 	#131 files changed, 3528 insertions(+)
 	#create mode 100644 .gitignore
 	#create mode 100644 LICENSE
 	#create mode 100644 README.md
 	#......

#删除分支
	git branch -D main
	#Deleted branch main (was a118552).

#将当前分支重命名为 main
	git branch -m main

#最后,强制更新您的存储库
	git push -f origin main
	#Enumerating objects: 105, done.
	#Counting objects: 100% (105/105), done.
	#Delta compression using up to 4 threads
	#Compressing objects: 100% (87/87), done.
	#Writing objects: 100% (105/105), 17.00 KiB | 756.00 KiB/s, done.
	#Total 105 (delta 41), reused 3 (delta 0), pack-reused 0
	#remote: Resolving deltas: 100% (41/41), done.
	#To https://github.com/zmrbak/WxOAuthManager
 	#+ a118552...edbcfa9 main -> main (forced update)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34

现在,再查看github上的提交历史,都清空了。但你的文件都在!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/970238
推荐阅读
相关标签
  

闽ICP备14008679号