在github建立一个项目

参考了GitHub起步---创建第一个项目

https://www.cnblogs.com/youqc/p/10488505.html

由于电脑是32位,只能下载了Git for windows Git-2.30.1-32-bit;

新建ssh文件

将远程仓库代码下载到本地

上传本地文件至远程仓库

上传文件至远程仓库

https://blog.csdn.net/unirrrrr/article/details/80330831

问题1:

$ git commit -m "xiaokcehui first upload"
Author identity unknown

*** Please tell me who you are.

解决方法就是:

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

上传命令

git push -u origin master

问题2:

fatal: 'origin' does not appear to be a git repository
fatal: Could not read from remote repository.

解决方法:

git remote add origin [email protected]:xxse/xx.git

下 划线是SSH地址

[email protected]:xiaokcehui/OceanMultibeamProc.git

注意传文件夹的时候

问题3:

$ git push -u origin master
error: src refspec master does not match any
error: failed to push some refs to 'https://github.com/xiaokcehui/OceanMultibeamProc.git'

远程没有分支master,只有main
$ git push -u origin main

下面的内容引自https://www.cnblogs.com/sylar5/p/12127870.html

git push 时发生错误 error: src refspec master does not match any. error: failed to push some refs to

很多相关解决办法都是最后要 push 到远端的 master 上,但很多其实要求不能把个人的修改内容直接 push 到 master 主分支。

因此,当我想将本地 feature/work1 分支的修改内容 push 到远端 develop 分支时,执行了:

git push origin develop

但却发生了错误,提示为 error: src refspec master does not match any. error: failed to push some refs to ...

最后发现问题是 git push 指令的格式为:git push [remote-name(通常为 origin)] [branch-name]

当将本地分支 push 到远端同名的分支时,branchname 只需要写一个分支名就可以(如直接克隆远程分支后修改再push);

但当要 push 到的远端分支名不同于本地分支名时,需要使用 git push origin [本地分支名:远端分支名],因此,在上述出错情况下,改为执行

git push origin feature/work1:develop

然后,就发现可以正确执行了。

更多咨询见xiaok海洋测绘网及同名公众号

猜你喜欢

转载自blog.csdn.net/u011115875/article/details/113820407