据我从 StackExchange 其他地方给出的答案中了解到 - 这个过程应该很简单:
a) git checkout master
b) git fetch origin
c) git pull origin
d) git push myremote # named aixtools
e) git checkout bpo-XXXXX
f) git merge master
g) git push myremote
直到步骤 g) 一切都按预期进行。当它是来自“来源”而不是“PR”的标签时,我试图保持同步,该过程运行良好。
非常感谢帮助、智慧、指导等:
目前步骤g
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is ahead of 'aixtools/bpo-11191' by 564 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git push aixtools
Username for 'https://github.com':
Password for 'https://[email protected]':
To https://github.com/aixtools/cpython.git
! [rejected] bpo-11191 -> bpo-11191 (non-fast-forward)
error: failed to push some refs to 'https://github.com/aixtools/cpython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
再一天:我在想,在阅读了有关重置和合并的更多内容以及其中的一些示例之后,我不是拉取本地主控,而是提交本地主控,然后将本地分支与本地“主控”合并也应该只是从“其他远程”“拉”作为一种合并。
无论如何 - 我恢复了本地情况的备份(当我用 git 为我尝试一些“新”时,总是制作一个副本)并且我希望以下内容回答有关“本地”状态的评论/查询
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git branch
* bpo-11191
master
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is up-to-date with 'aixtools/bpo-11191'.
nothing to commit, working tree clean
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git diff aixtools/bpo-11191
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]
或者
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git log --oneline | head -1
5a3284f (HEAD -> bpo-11191, aixtools/bpo-11191) Fix test_run and related tests Almost fix test_search_cpp
michael@x071:[/data/prj/python/git0/gcc-python3-3.7] aixtools/bpo-11191 | head -1 <
5a3284f (HEAD -> bpo-11191, aixtools/bpo-11191) Fix test_run and related tests Almost fix test_search_cpp
所以,也许这个问题需要重新表述:
- 我应该在本地合并吗?
- 从“其他远程”又名“项目所有者”拉取?
- 完全是别的东西吗?
下一次尝试 - 使用合并(也许我应该从不同的分支合并。“master”就是现在的 3.7(我猜测) - 所以也许我应该从 cpython/3.7 合并。
所以,现在我又觉得“howto”了。
基本上,我有一个 PR,我想保留/验证它仍然与当前的开发“同步” - 并用当前状态更新 PR。一个(我想要的)副作用是 PR 将通过“验证过程”再次重新评估。
我可能面临着“cpython”在下一个版本之前没有合并我的 PR 的情况。如果发生这种情况,我想尽可能使用 git 将我的开放 PR(又名 bpo-XXXXX)“合并”和/或“拉”到“AIX-release”分支中。
我看到的步骤是:
a) checkout the official release branch
b) create and checkout a new "aix-release" branch
c) merge my (local) branches, one at a time, into the new branch
d) commit (and push) the new "release"
因此,为了简化/验证合并到新版本中,我想知道,并将 bpo-XXXXX 与主分支和/或命名分支的最新“同步”“存储”。
我知道,当谈到 git 时,我是一名周日司机。这对你来说可能是显而易见的。但我认为对于很多人来说(至少我希望我并不孤单:smile:),git 在做什么方面并不简单。非常强大——是的——但我对它的力量感到不知所措。感谢您的帮助!
(仅供参考:最后一次尝试,新的失败 - 我很好奇使用了哪些具体步骤 - 签出、合并和推送 - 并使其全部正常工作?你收到我的 bpo 了吗,推送它,然后合并,然后提交(本地),然后推送 - 或使用其他一些工作流程 - 我正在寻找的是“自然”的工作流程。
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git merge cpython/master
...
Merge made by the 'recursive' strategy.
...
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git status
On branch bpo-11191
Your branch is ahead of 'aixtools/bpo-11191' by 564 commits.
(use "git push" to publish your local commits)
nothing to commit, working tree clean
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git push aixtools
Username for 'https://github.com':
Password for 'https://[email protected]':
To https://github.com/aixtools/cpython.git
! [rejected] bpo-11191 -> bpo-11191 (non-fast-forward)
error: failed to push some refs to 'https://github.com/aixtools/cpython.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git pull cpython
remote: Counting objects: 1908, done.
remote: Compressing objects: 100% (4/4), done.
remote: Total 1908 (delta 752), reused 751 (delta 751), pack-reused 1153
Receiving objects: 100% (1908/1908), 1.11 MiB | 2.01 MiB/s, done.
Resolving deltas: 100% (1334/1334), completed with 161 local objects.
From https://github.com/aixtools/cpython
fea0a12..b94d739 3.7 -> cpython/3.7
You asked to pull from the remote 'cpython', but did not specify
a branch. Because this is not the default configured remote
for your current branch, you must specify a branch on the command line.
michael@x071:[/data/prj/python/git0/gcc-python3-3.7]git pull cpython 3.7
From https://github.com/aixtools/cpython
* branch 3.7 -> FETCH_HEAD
Auto-merging README.rst
CONFLICT (content): Merge conflict in README.rst
Auto-merging Python/importlib_external.h
CONFLICT (content): Merge conflict in Python/importlib_external.h
Auto-merging Python/importlib.h
CONFLICT (content): Merge conflict in Python/importlib.h
Auto-merging Python/compile.c
CONFLICT (content): Merge conflict in Python/compile.c
Auto-merging Objects/frameobject.c
CONFLICT (content): Merge conflict in Objects/frameobject.c
Auto-merging Lib/test/test_sys_settrace.py
CONFLICT (content): Merge conflict in Lib/test/test_sys_settrace.py
Auto-merging Lib/test/test_random.py
CONFLICT (content): Merge conflict in Lib/test/test_random.py
Auto-merging Lib/pydoc_data/topics.py
CONFLICT (content): Merge conflict in Lib/pydoc_data/topics.py
Auto-merging Lib/importlib/_bootstrap_external.py
CONFLICT (content): Merge conflict in Lib/importlib/_bootstrap_external.py
Auto-merging Lib/enum.py
Auto-merging Include/patchlevel.h
CONFLICT (content): Merge conflict in Include/patchlevel.h
Auto-merging Doc/whatsnew/3.7.rst
CONFLICT (content): Merge conflict in Doc/whatsnew/3.7.rst
Auto-merging Doc/tools/templates/indexsidebar.html
CONFLICT (content): Merge conflict in Doc/tools/templates/indexsidebar.html
Auto-merging Doc/tools/extensions/pyspecific.py
Auto-merging Doc/library/re.rst
CONFLICT (content): Merge conflict in Doc/library/re.rst
Auto-merging Doc/library/dis.rst
CONFLICT (content): Merge conflict in Doc/library/dis.rst
Auto-merging Doc/library/configparser.rst
CONFLICT (content): Merge conflict in Doc/library/configparser.rst
Auto-merging .travis.yml
CONFLICT (content): Merge conflict in .travis.yml
Auto-merging .github/appveyor.yml
CONFLICT (content): Merge conflict in .github/appveyor.yml
Automatic merge failed; fix conflicts and then commit the result.
答案1
你可能想尝试一下git pull -r
。这(尝试)在本地更改“下方”添加远程更改,然后您可以git push
返回结果。
答案2
作为答案 - 因为我有一些对我有用的东西。
首先 - 我似乎遵循了错误的流程。
我现在使用的流程是:-启动-
- 从某处分叉
- 克隆我的 fork “作为 origin”
- 添加“某处”作为remote_origin
我将此目录称为“master”,例如,我的 cpython 分支的 cpython-master
我对此目录执行的“唯一”活动是从remote_origin“获取和/或拉取”,然后推送到“origin”。
这之前是有效的 - 但当我创建一个分支(作为 PR 提交但尚未合并到 remote_origin 中)并想要更新该 PR 以包含最新更新时,我迷失了方向。
那么,现在有什么作用呢?
- 从“我的叉子的”新克隆开始!
- 切换到我认为“最新”的标记分支
- 将我以前的分支拉/取到新分支
- 让一切正常工作 - 可能需要冲洗并重复回到此步骤
- 选择一个分支名称(可能与旧名称相同,也可能与新名称相同)
- 本地提交
- 推送到github
对我来说重要的不是尝试将来自任一来源的更新合并到我的“现有”分支中,而是转到来自我的分支的克隆上的“新”remote_origins 标记,然后将我的拉取请求“拉”到该情况中。
虽然我不太清楚为什么它效果更好 - 至少我不明白:
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.