在我能够推送到GIT'分支'之前需要更新GIT'master'

时间:2013-10-21 21:11:39

标签: git

我的开发有一个简单的GIT环境设置。一个是从远程主服务器克隆的主服务器,另一个是分支机构(也存在于远程主服务器上)。我通常在分支上工作,然后当我想推动我的更改时,我会执行通常的Git命令序列,如:

  1. git pull(确保一切都是最新的)
  2. git add
  3. git commit -m“message”
  4. git push
  5. 当我执行' git push '时,我收到一条消息说明:

    d96001d..d1cf61c  branch_release -> branch_release
    [rejected]        master -> master (non-fast-forward)
    error: failed to push some refs to '____________'
    hint: Updates were rejected because a pushed branch tip is behind its remote
    hint: counterpart. If you did not intend to push that branch, you may want to
    hint: specify branches to push or set the 'push.default' configuration variable
    hint: to 'simple', 'current' or 'upstream' to push only the current branch.
    

    要解决此问题,我会像这样切换分支

    git checkout master.
    

    这会在我的主人身上带来一大堆文件,前缀为“M”,意味着他们被修改了。然后我做

    git checkout branch_release
    

    它似乎也将同一组文件引入我的主人,我认为这不应该发生,因为我之前在这个分支上进行了GIT拉动。

    我的问题是,这是否是按照设计我还需要在推送其中一个分支之前更新主服务器?如果没有,我怎么设置错误,我该怎么做才能确保我只需要更新GIT分支。

1 个答案:

答案 0 :(得分:2)

如果您要解决非快速换档错误,则必须先。该错误表示远程主控已提交您的主人没有。

如果您只是在不指定分支的情况下进行推送,则会推送所有分支。您可以指定默认推送分支[2] 通过命令[1] 指定。

[1]通过push命令参数

指定它

所以你可能想做一个(用特定的分支推送)

git push origin branch_release

[2]定义默认推送分支

我认为这可能会有所帮助:

根据此站点,您可以指定默认推送分支,如下所示:

  

git config --global push.default current

<强> [编辑]

torek 指出 simple 将是git 2.0版的新git默认值。所以更新将(将来)解决这个问题/问题。

  

git config --global push.default simple

您可以在此处详细了解:

相关问题