git failed to push some refs to

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ 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=nettyGuide/<branch> master


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git push nettyGuide
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream nettyGuide master


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git push --set-upstream nettyGuide master

To https://gitee.com/ghostsugar/nettyGuide.git
 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://gitee.com/ghostsugar/nettyGuide.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.

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ 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=nettyGuide/<branch> master


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git pull nettyGuide master
warning: no common commits
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)
Unpacking objects: 100% (4/4), done.
From https://gitee.com/ghostsugar/nettyGuide
 * branch            master     -> FETCH_HEAD
 * [new branch]      master     -> nettyGuide/master
fatal: refusing to merge unrelated histories

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git push
fatal: No configured push destination.
Either specify the URL from the command-line or configure a remote repository using

    git remote add <name> <url>

and then push using the remote name

    git push <name>


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git commit
On branch master
nothing to commit, working tree clean

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git push nettyGuide
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream nettyGuide master


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ ^C

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$   git push --set-upstream nettyGuide master
To https://gitee.com/ghostsugar/nettyGuide.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/ghostsugar/nettyGuide.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.

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ 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=nettyGuide/<branch> master


Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$ git pull nettyGuide master
From https://gitee.com/ghostsugar/nettyGuide
 * branch            master     -> FETCH_HEAD
fatal: refusing to merge unrelated histories

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)
$   git push --set-upstream nettyGuide master
To https://gitee.com/ghostsugar/nettyGuide.git
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'https://gitee.com/ghostsugar/nettyGuide.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.

Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master)

出现错误的主要原因是github中的README.md文件不在本地代码目录中,可以通过如下命令进行代码合并【注:pull=fetch+merge]
$ git pull
--rebase nettyGuide master From https://gitee.com/ghostsugar/nettyGuide * branch master -> FETCH_HEAD First, rewinding head to replay your work on top of it... Applying: io Administrator@AB-201903201424 MINGW64 /d/IdeaProject/github/netty-guide (master) $ git push -u nettyGuide master Enumerating objects: 23, done. Counting objects: 100% (23/23), done. Delta compression using up to 4 threads Compressing objects: 100% (15/15), done. Writing objects: 100% (22/22), 5.69 KiB | 1.90 MiB/s, done. Total 22 (delta 3), reused 0 (delta 0) remote: Powered By Gitee.com To https://gitee.com/ghostsugar/nettyGuide.git f3be308..8939350 master -> master Branch 'master' set up to track remote branch 'master' from 'nettyGuide'.
原文地址:https://www.cnblogs.com/meijsuger/p/11209406.html