2015-04-01 25 views
2

我有一个分支是从develop(创建自Atlassian Stash)创建的,该分支有一些提交。当我尝试推送我的提交时,我得到一个关于更新被拒绝的错误,因为推送的分支提示位于其远程副本的后面。根据我的理解,这意味着别人承诺,所以我应该改变。然而,没有什么可以拉动的。有趣的是看着Atlassian Stash,我能够看到我的推动实际上已经过去了。混淆为什么Git认为我的分支技巧是在原点之后

$ git push 
To REPO_URL 
! [rejected]  develop -> develop (non-fast-forward) 
! [rejected]  feature/135-add-button-to-ticket-indicating -> feature/ 135-add-button-to-ticket-indicating (non-fast-forward) 
error: failed to push some refs to 'REPO_URL' 
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. 

我不确定我做错了什么,但我很想知道为什么这个特殊问题每隔几天就会出现一个丑陋的头。在过去,我只是强迫推动,但这并不能帮助我理解为什么这个问题首先发生。

如何诊断为什么会发生此问题?

+1

'git log --graph --oneline --decorate'显示你的远程分支和你的本地分支吗? – Makoto 2015-04-01 14:57:29

+0

我似乎无法找到任何地方日志消息的布局,但我相信我的远程分支是'origin/152-send-emails-rather-faxes'(红色字母),本地分支是' 152发送电子邮件 - 而不是传真“(绿色字母)。 – onetwothree 2015-04-01 15:58:21

+0

如果您的本地位于后面,则本地的提示将以图形方式显示在远程位置的提示之后。您还获取了最近的代码,对吗?这样的观点是完全准确的。 – Makoto 2015-04-01 15:59:30

回答

1

我前一段时间所面临的同样的问题,我也收到了以下

git push github master 
To [email protected]:Joey-project/project.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to '[email protected]:Joey-project/project.git' 

如果我没记错的话,一般的方法是使用下面的命令的变化:

git fetch github; git merge github/master 

你有没有试过这个链接Git push - suboptimal pack - out of memory?也许这可以帮助你进一步,以及..

2

看起来,如果仔细检查,Git推动更多的分支比你所知道的。

如果你只工作一个分支,当你键入git push想推一个分支,那么你需要你的全局配置调整为以下几点:

git config --global push.default current 

这将only push the branch that you are currently on到远程存储库。

相关问题