我如何将最后的N承诺集成到一个承诺中?
当前回答
如何回答与此类工作流相关的问题?
许多地方的承诺,混合了多种合并,从大师,最终推到远程,PR和合并到大师由审查员(是的,开发人员将更容易合并 - 经过大师,但团队认为这将减缓过程)。
我没有在这个页面上看到这样的工作流(这可能是我的眼睛)如果我正确地理解复制,多种融合将需要多种冲突解决方案。
所以,这似乎为我们工作。
git pull master git checkout -b new-branch git checkout -b new-branch-temp edit and commit a lot locally, merge master regularly git checkout new-branch git merge --squash new-branch-temp // puts all changes in stage git commit 'one message to rule them all' git push Reviewer does PR and merges to master。
其他回答
例如,如果您想在一个分支(远程存储库)中排除最后3个承诺,例如: https://bitbucket.org
我所做的就是
git reset --soft HEAD~3 git commit git push 起源 <branch_name> --force
在问题上,可以是双重的“最后”是什么意思。
* commit H0
|
* merge
|\
| * commit B0
| |
| * commit B1
| |
* | commit H1
| |
* | commit H2
|/
|
可以使用折扣,但以不同的方式,然后在其他提到的答案:
首頁 / 首頁 / 2
这将向您展示选择选项(如其他答案中提到的):
pick B1
pick B0
pick H0
pick B1
pick B0
s H0
在保存和退出后,将执行命令,然后在H1之后,这意味着它将要求你重新解决冲突(在那里,主将是H1首先,然后积累命令,当它们被应用)。
退缩结束后,您可以选择失败的 H0 和 B0 消息:
* commit squashed H0 and B0
|
* commit B1
|
* commit H1
|
* commit H2
|
P.S. 如果你只是做一些重新设置到BO:(例如,使用重新设置 - 混合,这里详细解释 https://stackoverflow.com/a/18690845/2405850):
git reset --mixed hash_of_commit_B0
git add .
git commit -m 'some commit message'
最方便的方式是使用 GitHub 桌面. 只需在历史中选择所有命令,右键单击并选择“Squash x 命令”:
此分類上一篇
您可以按照 git 命令使用。
git rebase -i HEAD~n
n(=4在这里)是最后的承诺的数字,然后你得到了以下选项,
pick 01d1124 Message....
pick 6340aaa Message....
pick ebfd367 Message....
pick 30e0ccb Message....
更新如下,选择一个承诺,并将其他人推到最新的,
p 01d1124 Message....
s 6340aaa Message....
s ebfd367 Message....
s 30e0ccb Message....
详细信息点击链接
首先,我知道我的功能分支和当前主分支之间的承诺数量。
git checkout master
git rev-list master.. --count
然后,我创建另一个基于我的功能分支的分支,保持我的功能分支无触。
最后,我跑
git checkout my-feature
git checkout -b my-rebased-feature
git checkout master
git checkout my-rebased-feature
git rebase master
git rebase head^x -i
// fixup/pick/rewrite
git push origin my-rebased-feature -f // force, if my-rebased-feature was ever pushed, otherwise no need for -f flag
// make a PR with clean history, delete both my-feature and my-rebased-feature after merge
希望能帮忙,谢谢。
推荐文章
- 为什么我需要显式地推一个新分支?
- 如何撤消最后的git添加?
- Rubymine:如何让Git忽略Rubymine创建的.idea文件
- Gitignore二进制文件,没有扩展名
- Git隐藏错误:Git隐藏弹出并最终与合并冲突
- 了解Git和GitHub的基础知识
- 没有。Git目录的Git克隆
- Git与Mercurial仓库的互操作性
- 忽略git中修改(但未提交)的文件?
- “git restore”命令是什么?“git restore”和“git reset”之间有什么区别?
- Git合并与强制覆盖
- Git拉另一个分支
- 在Bash命令提示符上添加git分支
- 如何更改Git日志日期格式
- git pull -rebase和git pull -ff-only之间的区别