Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

使用git rebase拆分过去的某次提交 #23

Open
wujunchuan opened this issue Mar 27, 2017 · 1 comment
Open

使用git rebase拆分过去的某次提交 #23

wujunchuan opened this issue Mar 27, 2017 · 1 comment

Comments

@wujunchuan
Copy link
Owner

使用场景

你正在做一个项目,然而在过去的某个时候,你把两个重大的改动提交到了一个版本A中。 直到又进行了几次提交之后,你才发现有必要将之前那两个重大改动拆分成版本A和版本B。

使用步骤

  1. git rebase -i HASH 返回到你需要拆分的版本
  2. git reset HEAD~返回到你需要拆分的上一个版本(此时的代码保持的版本A与版本B的共同内容)
  3. 删除版本记录git rm file --cache
  4. 拆分文件,提交版本A的代码 gti commit --amend -m ‘Version A’
  5. 将版本B的代码加入,提交版本B的代码 git commit -m ‘Version B
  6. 结束交互式rebase git rebase - -contine
  7. 然后你就会发现,需要拆分的版本已经被拆分成两次提交(VersionA与VersionB)
@wujunchuan wujunchuan added the Git label Mar 27, 2017
@wujunchuan
Copy link
Owner Author

原文链接

@wujunchuan wujunchuan removed the Git label Nov 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant