[英]How to pull specific commits in git rebase
我的分支落后5次提交。
muralish@vnc9[~/git/task](task-68↓3| ✓)$git status
# On branch task-68
# Your branch is behind 'origin/task-68' by 5 commits, and can be fast-forwarded.
#
nothing to commit, working directory clean
muralish@vnc9[~/git/task](desflow-68↓3| ✓)$
這些提交是A-> B-> C-> D-> E。 我如何只獲取與將C提交到工作目錄相關的更改。
它嘗試了git rebase -i,但是根本不會列出該提交。 它輸出以下信息。
noop
# Rebase 484a22b..b7fa802 onto 484a22b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop f
任何幫助表示贊賞。
嘗試
git cherry-pick <C-sha>
如果您不希望將這些更改存儲為新的提交使用
git reset HEAD~1
更改將不會被暫存或提交。
更新:
如果您希望自己的分支似乎合並了task-68的那5個提交,而實際上它只包含您可以編寫的提交C(在摘櫻桃之后):
git merge -s ours task-68
更新2:
保持本地task-68
分支與origin/task-68
相同是一種常見的做法,因此,如果您想從父分支中忽略一些提交,最好事先進行分支:
git checkout -b task-68-wip
此后,如上所述繼續進行櫻桃選擇和合並。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.