清空Github仓库方法 |
您所在的位置:网站首页 › github的仓库 › 清空Github仓库方法 |
正文
学习Git的使用还是应该清楚原理,理解加记忆会更可靠 ❗注意:新建一个空的本地仓库是不能顺利推送到远程仓库的,因为它们没有历史关系。但你可以先把原仓库的.git目录复制到一个空的文件夹内,然后再按照下面的提示做: 进入空文件夹内,鼠标右键打开Git Bash![]() 做最后一步时,从本地仓库向Github远程仓库推送更新时可能会发生这样的错误: $ git push -u origin master To github.com:code-2023/Java.git ! [rejected] master -> master (fetch first) error: failed to push some refs to 'github.com:code-2023/Java.git' hint: Updates were rejected because the remote contains work that you do hint: not have locally. This is usually caused by another repository pushing hint: to the same ref. You may want to first integrate the remote changes hint: (e.g., 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.这里有条强制推送命令,本义是从历史不相关的本地仓库强制推送到另一个远程仓库,可以使用 --force 参数,而且Github仓库的历史记录如commit次数应该会被重置,就好像向新仓库进行第一次推送一样。 git push --force origin master但我试了以后,本地空仓库不仅成功推送到了Github,而且仓库的commit记录还在,因为你的空仓库用的是原仓库的.git目录,继承了原仓库的历史。 |
今日新闻 |
推荐新闻 |
CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3 |