我想将develop
分支中已完成的更改提取并合并到我的分支OneUser
中。
我在做:
git checkout OneUser
git fetch origin develop
...
Unpacking objects: 100% (21/21), done.
From https://github.com/.........
* branch develop -> FETCH_HEAD
e2f......... d36 develop -> origin/develop
git merge origin develop
Already up-to-date.
git commit -a
(我知道已经做了一些改动,所以通常它会给我一些冲突?或者它已被改变了什么?)
然后,如果我试图推动我的变化发展:
git checkout OneUser
git push -u origin develop
! [rejected] develop -> develop (non-fast-forward)
error: failed to push some refs to 'https://github.com/.../.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.
=========Α工作流程========================
git checkout -b OneUser develop
git branch --set-upstream-to=origin/develop
//fetch from develop branch and merge to OneUser
git checkout OneUser
git fetch origin develop
git merge origin/develop
If you have any conflicts ,solve , add files and commit.
//work on branch
git add “files”
git commit -m “message”
//push to develop
git push origin OneUser:develop
答案 0 :(得分:2)
如果我理解正确,您希望将本地分支OneUser
推送到远程分支develop
在这种情况下,你必须告诉git所以
git push origin OneUser:develop
这告诉git将你的分支(OneUser)的源存储库推送到远程的develop分支。
您为何遇到错误:
git checkout OneUser
git push -u origin develop
! [rejected] develop -> develop (non-fast-forward)
使用git push -u origin develop
,您指示git:
推送名为" develop"的 本地 分支到与名称匹配的远程分支。由于您已合并到OneUser
分支,但未更新开发分支的本地副本,因此git无法推送。您还可以在错误消息中看到它:
! [rejected] develop -> develop (non-fast-forward)
更新#1
在您的方案中,您总是希望将OneUser
分支与develop
同步,在这种情况下,您可以通过发出命令(仅限1次)明确要求git对其进行处理/ p>
git branch --set-upstream-to=origin/develop
您可以通过以下方式检查正在跟踪的远程分支:
git status -sb
然后就是推动你的本地"分支,git会知道在哪里推它。
git push origin OneUser
答案 1 :(得分:0)
我相信你正在寻找“git pull --rebase”。应该集成远程更改,允许你推送