更新1:
现在,当我重新设置基准时,我面临着冲突。在我修改代码之后。您能告诉我执行什么命令来消除冲突吗? 在下面提供状态
sports/code/file (branchB)
$ git pull --rebase origin branchA
From https://gitlab.sports.com
* branch branchA -> FETCH_HEAD
First, rewinding head to replay your work on top of it...
Applying: wip html fixes
Using index info to reconstruct a base tree...
M sports/ajax.js
Falling back to patching base and 3-way merge...
Auto-merging sports/ajax.js
CONFLICT (content): Merge conflict in sports/ajax.js
error: Failed to merge in the changes.
Patch failed at 0001 wip html fixes
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git rebase --continue".
If you prefer to skip this patch, run "git rebase --skip" instead.
To check out the original branch and stop rebasing, run "git rebase --abort".
sports/code/file (branchB|REBASE 1/2)
$ git status
rebase in progress; onto 89898989892323
You are currently rebasing branch 'branchB' on '89898989892323'.
(fix conflicts and then run "git rebase --continue")
(use "git rebase --skip" to skip this patch)
(use "git rebase --abort" to check out the original branch)
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add <file>..." to mark resolution)
both modified: sports/ajax.js
no changes added to commit (use "git add" and/or "git commit -a")
git pull --rebase origin A
进行了git rebase git push -f origin B
,我的代码将单独进入分支B还是也进入分支A。$ git status
On branch B
Your branch and 'origin/B' have diverged,
and have 7 and 1 different commits each, respectively.
(use "git pull" to merge the remote branch into yours)
nothing to commit, working directory clean
答案 0 :(得分:1)
我从分支A创建了一个新的本地分支B。
a--a--a (A)
\
b (B, origin/B, meaning this is the initial commit pushed to the remote repo)
现在,如果我执行
git push -f origin B
,我的代码将单独进入分支B
还是也进入分支A
。
仅是分支B,但该分支B将包括分支A提交。
那是因为,当您这样做时:
git checkout B
git pull --rebase origin A
您来自
a--a--a--a--a--a (A)
\
b--B--B--B--B--B (local work B)
^
(origin/B)
收件人:
(A)
v
a--a--a--a--a--a--b'--B'--B'--B'--B'--B' (new rebased B work, on top of A)
\
b
(still origin/B)
这就是为什么您看到:
Your branch and 'origin/B' have diverged, and have 7 and 1 different commits each, respectively.
就您而言,如果git status
向您表明您正在使用B,则可以这样做
git push --force
您将得到:
a--a--a--a--a--a--b'--B'--B'--B'--B'--B' (B, origin/B)
您的分支B现在包括来自A的提交,但是分支A保持不变。