在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 "you@example.com"
  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 git@github.com:xxse/xx.git

下 划线是SSH地址

git@github.com: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海洋测绘网及同名公众号

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

xiaokcehui

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值