例如在Gitee上:https://gitee.com/xxx/yyy.git
在本地源码的根目录下运行如下命令,例如:c:\yyy
git init
git add .
git status
git commit -m “The first commit to remote repo”
git status
git remote add origin https://gitee.com/xxx/yyy.git
git pull origin master
可能会报错:
$ git pull origin master
remote: Enumerating objects: 5, done.
remote: Counting objects: 100% (5/5), done.
remote: Compressing objects: 100% (5/5), done.
remote: Total 5 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (5/5), 2.84 KiB | 104.00 KiB/s, done.
From https://gitee.com/qp1886358/kafka-springboot
* branch master -> FETCH_HEAD
* [new branch] master -> origin/master
fatal: refusing to merge unrelated histories
有两种选择解决以上问题:
运行命令:
git pull origin master --allow-unrelated-histories
如果有冲突,需要手动解决冲突,然后运行命令:
git add
git commit -m “Solved all the conflicts”
git pull --rebase origin master
如果有冲突,需要手动解决冲突,然后运行命令:
git add
git rebase --continue
如果要退出rebase,可以运行命令:
git rebase --abort
运行命令:
git push --set-upstream origin master
或
git push -u origin master