【问题标题】:Trouble with adding repository to GitHub via Gitbash/command line通过 Gitbash/命令行向 GitHub 添加存储库时遇到问题
【发布时间】:2018-11-03 13:52:58
【问题描述】:

当我尝试通过命令行将项目文件夹推送到GitHub 时,我收到错误消息“

致命:不是 git 存储库(或任何父目录):

.git”,然后我将链接粘贴到存储库并输入“git push -u origin master”。这里发生了什么?

【问题讨论】:

  • 是您的本地目录是 Git 存储库吗? Git是分布式的。您需要有一个本地存储库,然后才能推送到任何地方。听起来您可能需要阅读介绍性教程。

标签: github command-line repository git-bash


【解决方案1】:
If you want to do create fresh one and delete existing one then follow below steps:

Open git bash command prompt 

--remove the history from
rm -rf .git

--recreate the repo
git init
git add .
git commit -m "initial commit"

--push to the github repo
git remote add origin git@github.com<you git loc>
git push -u --force origin master

【讨论】:

  • 在推荐rm -rf .git和git push --force之类的内容时请包含警告。这些是危险的命令,OP 需要了解它们的作用,而不是盲目地复制和粘贴它们。在任何情况下,看起来都没有是要删除的.git/ 目录。错误信息表明本地不存在 Git 仓库。
猜你喜欢
  • 2013-12-21
  • 1970-01-01
  • 2018-03-05
  • 1970-01-01
  • 2015-07-23
  • 2023-03-29
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多