奇怪的git推送错误

奇怪的git推送错误,git,github,Git,Github,在第二次git push中遇到错误,我只想在同一个Pull请求中添加一些新的更改,有什么想法可以解决这个问题吗?谢谢 Git操作 git checkout -b newFooBranch git add <name of file changed> git commit -m 'add some initial changes' git push origin newFooBranch // make some changes git add <name of same fi

在第二次git push中遇到错误,我只想在同一个Pull请求中添加一些新的更改,有什么想法可以解决这个问题吗?谢谢

Git操作

git checkout -b newFooBranch
git add <name of file changed>
git commit -m 'add some initial changes'
git push origin newFooBranch

// make some changes
git add <name of same file changed>
git commit -m 'add some new changes on the same file'
// met with error when executing below command
git push origin newFooBranch
编辑1

To git@github.com:foo/goo.git
 ! [rejected]        newFooBranch -> newFooBranch (non-fast-forward)

error: failed to push some refs to 'git@github.com:foo/goo.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
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> newFooBranch
git拉
当前分支没有跟踪信息。
请指定要与哪个分支合并。
有关详细信息,请参见git pull(1)。
吉特拉力
如果您希望为此分支设置跟踪信息,可以通过以下方式进行设置:
git branch——将上游设置为=origin/newfoodbranch
问候,, 林

执行以下任一操作:

git pull

或:


在推送更改之前。

如果没有其他人提交到该分支并推送,则您已经移动了本地头指针,可能是使用了
git checkout
命令。只要看看github,看看哪些提交与本地提交不同。@AndyRay,谢谢并投票赞成。“看看github,看看哪些提交与本地提交不同”是什么意思?github.com上有没有可以看的部分?谢谢Nishant,投票通过,在执行git pull时遇到错误,如果你有任何想法,请发表在我原始帖子的编辑1部分,这将非常好。请尝试
git pull origin newFooBranch
。您也可以执行
git branch——如错误消息所示,将上游设置为=origin/newFooBranch newFooBranch
。基本上,git不知道从哪个分支提取(因为新分支是在没有任何上游的情况下创建的),所以它要求您更具体一些。一旦您使用
--将上游设置为
,您就不必在pull中指定branchname,只需
git pull
即可。
git remote update
git rebase origin/newFooBranch