作者:谦谦骄子_458 | 来源:互联网 | 2023-10-12 13:59
两台电脑,pc1pc2.
两台电脑,pc1 pc2.
pc1 push project1 到 https://xxxx@github.com/xxxx/...
1 2 3 4 5
| git init
git add project1/
git commit -m "from pc1"
git remote add origin ttps://xxxx@github.com/xxxx/yyyy.git
git push -u origin master |
成功了。
现在需要将pc2上面的project2 ,push到 https://xxxx@github.com/xxxx/...
下面在pc2上使用相同的代码
1 2 3 4 5
| git init
git add project2/
git commit -m "from pc1"
git remote add origin https://xxxx@github.com/xxxx/yyyy.git
git push -u origin master |
报错
error: failed to push some refs to 'https://xxxx@github.com/xxxx/...'
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 2 3 4 5 6 7
| rm -rf .git
git init
git add project2/
git commit -m "from pc1"
git remote add origin https://xxxx@github.com/xxxx/yyyy.git
git pull
git push -u origin master |
报错:
error: failed to push some refs to 'https://xxxx@github.com/xxxx/...'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
代码继续修改为
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
| rm -rf .git
git init
git add project2/
git commit -m "from pc1"
git remote add origin https://xxxx@github.com/xxxx/yyyy.git
git pull origin master
报错
From https://xxxx@github.com/xxxx/yyyy.git
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
fatal: refusing to merge unrelated histories
git push -u origin master
报错
error: failed to push some refs to 'https://xxxx@github.com/xxxx/yyyy.git' |
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
请问,如何解决?