Git 在没有良好初始提交的情况下擦除远程分支历史记录
我有两个本地回购协议:Git 在没有良好初始提交的情况下擦除远程分支历史记录,git,Git,我有两个本地回购协议:a-public-project和top secret,在对这两个本地回购协议进行多次提交后,我在GitHub上创建了一个新的空回购协议,它将是a-public-project的远程回购协议,但我不小心推了top secret: cd C:/Git/top-secret git remote add github https://github.com/me/a-public-project.git git push -u github master 在恐慌模式下,我在线搜
a-public-project
和top secret
,在对这两个本地回购协议进行多次提交后,我在GitHub上创建了一个新的空回购协议,它将是a-public-project
的远程回购协议,但我不小心推了top secret
:
cd C:/Git/top-secret
git remote add github https://github.com/me/a-public-project.git
git push -u github master
在恐慌模式下,我在线搜索并发现以下结果:
幸运的是,在这个特定的实例中,我能够使用GitHub网站删除repo,然后推送正确的本地repo,但是如果我无法控制的repo再次发生这种情况,我该怎么办?一种快速恢复的方法是从远程删除主分支
git push github :master
或者您可以快速跳到a-public-project
并强制将其覆盖
cd C:/Git/a-public-project
git remote add github https://github.com/me/a-public-project.git
git push -u github master --force
我在这里看到冒号的意义: