1.最好使用ssh连接,不知道是不是https的问题,会报错:
fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.
然后查看$ git remote -v,则出现
origin master (fetch)
origin master (push)
而正确的格式应为
origin git@github.com:githubName/仓库名.git (fetch)
origin git@github.com:githubName/仓库名.git (push)
这时应该
git init
git remote rm origin
git remote add origin git@github.com:githubName/仓库名.git(注:ssh链接)
这样就好了!
2.在git commit -m "仓库名"后报错:
On branch master
nothing to commit, working tree clean
这是因为git add . 将所有文件添加到缓存区,git commit -m "仓库名"将文件提交到本地仓库,然后再次git commit -m "仓库名"反复提交重复的东西就会报这个错误。所以这时只需
git push origin master
就好啦!!!
记录我的完整流程!对我必成功,其他人的流程不知道为啥不行
git clone git@github.com:githubName/仓库名.git
git init
git remote add origin git@github.com:githubName/仓库名.git
git add .
git commit -m "备注"
git push origin master
更新:报错
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the RSA key sent by the remote host is
SHA256:uNiVztksCsDhcc0u9e8BujQXVUpKZIDTMczCvj3tD2s.
Please contact your system administrator.
Add correct host key in /c/Users/NaTingting/.ssh/known_hosts to get rid of this message.
Offending RSA key in /c/Users/NaTingting/.ssh/known_hosts:1
RSA host key for github.com has changed and you have requested strict checking.
Host key verification failed.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
删除user/.ssh/目录下的known_hosts文件,再重新输入命令就好了。
本文讲述了遇到'origin does not appear to be a git repository'错误时,如何通过SSH连接、初始化远程仓库、添加远程仓库和解决权限问题的详细步骤,包括git clone、git init、git remote操作和SSH警告的处理。
1462

被折叠的 条评论
为什么被折叠?



