使用Git上传项目代码到Gitee遇到的问题
提示错误如下:
$ git push origin master
To gitee.com:chesnyhh/hcsgsal.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'gitee.com:chesnyhh/hcsgsal.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.
解决方法:
$ git pull //1. 输入git pull
There is no tracking information for the current branch.
Please specify which branch you want to merge with.
See git-pull(1) for details.
git pull <remote> <branch>
If you wish to set tracking information for this branch you can do so with:
git branch --set-upstream-to=origin/<branch> master
$ git pull origin master //2. 再输入git pull origin master
From gitee.com:chesnyhh/hcsgsal.git
* branch master -> FETCH_HEAD
fatal: refusing to merge unrelated histories
$ git pull origin master --alow-unrelated-histories //3. 再输入这行
$ git push -u origin master -f //4. 最后输入这个代码 就可以上传项目代码
Enumerating objects: 105, done.
Counting objects: 100% (105/105), done.
Delta compression using up to 4 threads
Compressing objects: 100% (88/88), done.
Writing objects: 100% (105/105), 154.53 KiB | 1.91 MiB/s, done.
Total 105 (delta 24), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (24/24), done.
remote: Powered by GITEE.COM [GNK-5.0]
To gitee.com:chesnyhh/hcsgsal.git
+ 8161726...276a37e master -> master (forced update)
Branch 'master' set up to track remote branch 'master' from 'origin'.
完。。。