3 回答
TA贡献1795条经验 获得超7个赞
搬到一个新的分支机构
警告:git branch newbranch
git reset --hard HEAD~3
# Note: Any changes not committed will be lost.git branch newbranch # Create a new branch, saving the desired commitsgit reset --hard HEAD~3 # Move master back by 3 commits (Make sure you know how many commits you need to go back)git checkout newbranch # Go to the new branch that still has the desired commits
HEAD~3
git reset --hard a1b2c3d4
警告:git rebase
master
--no-fork-point
branch.autosetuprebase always
转移到现有的分支
git checkout existingbranch git merge master git checkout master git reset --hard HEAD~3 # Go back 3 commits. You *will* lose uncommitted work.git checkout existingbranch
TA贡献1827条经验 获得超9个赞
A-B-C-D-E (HEAD) ↑ master
git branch newBranch
:
newBranch ↓ A-B-C-D-E (HEAD) ↑ master
git reset --hard HEAD~2
:
newBranch ↓ A-B-C-D-E (HEAD) ↑ master
git reset
TA贡献1799条经验 获得超9个赞
一般来说.。
步骤1-注意从您希望在 newbranch
git checkout master git log
newbranch
9aa1233
453ac3d
612ecb3
注:
您可以使用前七个字符或整个提交哈希。
步骤2-将它们放到 newbranch
git checkout newbranch git cherry-pick 612ecb3 git cherry-pick 453ac3d git cherry-pick 9aa1233
或(在Git 1.7.2+上,使用范围)
git checkout newbranch git cherry-pick 612ecb3~1..9aa1233
樱桃采摘
- 3 回答
- 0 关注
- 1343 浏览
添加回答
举报