本地新仓库能推送到已有的远程仓库吗?

我码云上有个git仓库
如果我在本地又 git init 初始化了一个仓库,
那么这个新的仓库能 push 到码云上的仓库,和码云上的仓库合并吗?

我试了一下,提示出错,我不知道是我操作的问题还是不可以这样做!

$ git push -u origin master
To gitee.com:***
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'gitee.com:***'
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.
阅读 1.7k
1 个回答

1.把本地仓库的远端地址设置成你码云仓库的地址
2.然后运行git pull获取
3.再commit 和 push
(不过为啥不把你码云的仓库克隆到本地然后在里面修改呢)

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进