Discuss / Git / 连接远程库如果报错 fatal: not a git repository (or any of the parent directories): .git

连接远程库如果报错 fatal: not a git repository (or any of the parent directories): .git

Topic source

按老师步骤连接远程库报错:

fatal: not a git repository (or any of the parent directories): .git

解决方法:

先输入:

$ git init

$ git init

Initialized empty Git repository in C:/Users/onilo/.git/

再重新连接远程库:

$ git remote add origin git@https://github.com/bljx200/learngit.git

即可添加

$ git push -u origin master

error: src refspec master does not match any

error: failed to push some refs to 'https://github.com/hhh551/testgit.git'

这是怎么回事请问?

i叶子青

#3 Created at ... [Delete] [Delete and Lock User]

这是空仓库  随便新建一个 txt  commit 后就可以了

补充一下,我原本也是遇到这个问题。不过我的情况是是创建版本库后把git bush关掉了,第二天又来学习创建远程库,所以一开始的目录并不是我原来的版本库learngit。

而我又不想重新创建一个版本库来关联远程库怎么办?只需要在一开始输入cd learngit,这样就可把目录切换到一开始的learngit库中,从而进行下一步操作。

All is well

#5 Created at ... [Delete] [Delete and Lock User]

路径要在cd /home/.......那个路径下


  • 1

Reply