git ![rejected] master -> master (non-fast-forward) 在一个新的最新分支上
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27731259/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
! [rejected] master -> master (non-fast-forward) on a new up-to-date branch
提问by CodyBugstein
In my repo, I have a master
branch, and a new
branch.
在我的回购中,我有一个master
分支和一个new
分支。
I've been working on new
for a while, making commits, and pushes as I go. I decided now to branch off new
and call it newest
. So I did
我已经工作new
了一段时间,不断地提交和推送。我现在决定分支new
并调用它newest
。所以我做了
git checkout -b "newest"
and the branch was successfully created. I added a file, and started working on it. I committed my changes a couple of times.
并且分支创建成功。我添加了一个文件,并开始处理它。我提交了几次更改。
BUT when I try to push this new branch and my changes to it to origin
, I get this error:
但是,当我尝试将这个新分支和我对它的更改推送到 时origin
,我收到此错误:
C:\wamp\www\myproj>git push origin
To https://github.com/Imray/Proj.git
! [rejected] master -> master (non-fast-forward)
! [rejected] new -> new (non-fast-forward)
error: failed to push some refs to 'https://github.com/Imray/Proj.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and 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.
So, as specified in the instructions, I tried git pull
, but then I got:
因此,按照说明中的说明,我尝试了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> newest
I'm stuck.
我被困住了。
How do I push my new branch and the changes to github
?
如何将我的新分支和更改推送到github
?
回答by VonC
Check your git config push.default
. It might be on "matching
", since it tries to push all existing branches.
That was the default before Git 2.0+.
检查您的git config push.default
. 它可能在“ matching
”上,因为它试图推送所有现有的分支。
这是Git 2.0+ 之前的默认设置。
I would recommend setting it to "simple
", in order to push only the current branch.
我建议将其设置为“ simple
”,以便仅推送当前分支。
That being said, to push a branch, you need (for the first push) to setup an upstream branch.
话虽如此,要推送一个分支,您需要(第一次推送)设置一个上游分支。
For a branch never pushed before:
对于以前从未推送过的分支:
git push -u origin newest
For a branch which does exists on the upstream repo:
对于上游 repo上确实存在的分支:
git branch --set-upstream-to=origin/master master
git branch --set-upstream-to=origin/new new
Then a git checkout master ; git pull would
work.
然后是git checkout master ; git pull would
作品。
回答by Gujarat Santana
try this :
尝试这个 :
- git pull --rebase https://github.com/yoursmaster/name of your branch
- git pull --rebase https://github.com/yoursmaster/你的分支名称
hope it helps
希望能帮助到你