git 本地仓库首次推送到远程
git init
git add .
git commit -m 'first commit'
git remote add <远程仓库地址>
$ git push origin master:master
warning: auto-detection of host provider took too long (>2000ms)
warning: see https://aka.ms/gcm/autodetect for more information.
To https://gitee.com/chaung_sun/fa_auto_search.git
! [rejected] master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/chaung_sun/fa_auto_search.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.
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git pull --allow-unrelated-histories # 未解决问题
remote: Enumerating objects: 4, done.
remote: Counting objects: 100% (4/4), done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 4 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (4/4), 2.07 KiB | 124.00 KiB/s, done.
From https://gitee.com/chaung_sun/fa_auto_search
* [new branch] master -> origin/master
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
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git push origin master:master
To https://gitee.com/chaung_sun/fa_auto_search.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/chaung_sun/fa_auto_search.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.
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git fetch origin # 拉取远程仓库的更新
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git merge origin/master # 与本地仓库合并,拉去失败,需要加--allow-unrelated-histories
fatal: refusing to merge unrelated histories
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git merge origin/master --allow-unrelated-histories # 成功
Merge made by the 'ort' strategy.
README.en.md | 36 ++++++++++++++++++++++++++++++++++++
README.md | 39 +++++++++++++++++++++++++++++++++++++++
2 files changed, 75 insertions(+)
create mode 100644 README.en.md
create mode 100644 README.md
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
$ git push origin master:master # 推送成功
Enumerating objects: 75, done.
Counting objects: 100% (75/75), done.
Delta compression using up to 12 threads
Compressing objects: 100% (72/72), done.
Writing objects: 100% (74/74), 18.40 MiB | 1.95 MiB/s, done.
Total 74 (delta 12), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-6.4]
To https://gitee.com/chaung_sun/fa_auto_search.git
2b23de1..f406766 master -> master
win@DESKTOP-MFK5B06 MINGW64 /d/jlc_auto_test/fa_search_test (master)
遇到的问题:
https://blog.csdn.net/m0_63217468/article/details/126667119
https://blog.csdn.net/IT_SoftEngineer/article/details/107133313
https://blog.csdn.net/junruitian/article/details/88361895/
本文来自博客园,作者:chuangzhou,转载请注明原文链接:https://www.cnblogs.com/czzz/p/17534636.html