Discuss / Git / github本地项目切换关联gitee远程

github本地项目切换关联gitee远程

Topic source

1、github有个learGit项目,里面有readme.txt、env.txt等文件。先把项目拉取到本地

2、在码云新建一个远程库,并添加了readme.txt文件。

3、本地的git项目删除github远程库关联,重新关联码云远程库。

4、执行git status,提示“nothing to commit, working tree clean”

问题:这样要怎么把原来git项目里面的文件提交到码云远程库上呢?总不能每个文件手动更改下。在添加提交上去?

5、我改了文件后,要提交远程gitee被拒绝了:

git push --set-upstream origin master

To https://gitee.com/eadio/learnGit.git

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

error: failed to push some refs to 'https://gitee.com/eadio/learnGit.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.

楚歌

#2 Created at ... [Delete] [Delete and Lock User]

我遇到一样的情况,通过两步,解决了问题。

1。$ git remote add gitee https://gitee.com/用户名/learngit,

不是$ git remote add gitee git@gitee.com:用户名/learngit

2。添加公钥以后,在Git Bash:

$ ssh -T git@gitee.com

————问题解决————


  • 1

Reply