本地仓库关联远程仓库有关问题解决

web操作:

  1. 首先去网站新建GitHub仓库。

本地操作:

  1. 进入到要建仓库的目录
  2. git init。
  3. it remote add origin git@github.com:RayHauton/***.git
  4. git push -u origin master ------><font color='red'>此时可能会有问题</font>

如果在网站中新建仓库的时候新添了README文件的时候,此时push不上去,会报如下错误:

$ git push --set-upstream origin master

To github_second:RayHauton/ScheduleManagerApp.git

! [rejected] master -> master (fetch first)

error: failed to push some refs to 'git@github_second:RayHauton/ScheduleManagerApp.git'

hint: Updates were rejected because the remote contains work that you do

hint: not have locally. This is usually caused by another repository pushing

hint: to the same ref. You may want to first integrate the remote changes

hint: (e.g., 'git pull ...') before pushing again.

hint: See the 'Note about fast-forwards' in 'git push --help' for details.

解决方案:

$ git pull --rebase origin master

此时本地方会多出README文件。然后可以进行

git push -u origin master

的操作。此时就成功了

 

push完毕之后,新建分支并且关联到远程分支的时候依然会有问题,表现如下

如果远程还有一个dev分支,如果在本地git checkout -b dev新建dev以后,然后直接关联

git --set-upstream-to origin/dev

会报错,如下:

error: the requested upstream branch 'origin' does not exist

hint:

hint: If you are planning on basing your work on an upstream

hint: branch that already exists at the remote, you may need to

hint: run "git fetch" to retrieve it.

hint:

hint: If you are planning to push out a new local branch that

hint: will track its remote counterpart, you may want to use

hint: "git push -u" to set the upstream config as you push.

根据错误中的提示运行:

git fetch

然后在进行关联就行了。

 

 

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值