【发布时间】:2013-05-01 05:05:53
【问题描述】:
这个问题与其他问题的不同之处在于,我想在恢复一些提交的同时保留一些提交。
这是我的设置。
Upstream repo on github (public repo which I don't own)
Personal repo on my server(git clone --bare $upstream)
我的工作流程是这样的:
Need to customize my personal branch
1. check out origin/master(Personal)
2. make changes
3. push to origin/master
Need to get new feature or bug fix from the original author(github)
1. git fetch upstream
2. git merge upstream/master
现在我发现上游/master 有一个错误并想要恢复,
我如何回到最后一次获取/合并上游之前的状态?
编辑。
假设
- 我在上游合并了
- 我合并了团队成员推送到 origin/master(Personal) 的内容
现在我想撤消第 1 步。
git reset --hard commit_sha_of_one_prior_the_merge_1
(虽然找到sha并不容易。git log显示了很多commit sha的上游,所以不容易找到 commit-sha-of_one_prior_the_merge_1 不是
upstream而是origin/master)
如何保持第 2 步的合并?
假设一个稍微复杂的场景
- 我在上游合并
- 我合并了其他团队成员推送到个人的内容
- 我也将我的工作推送到个人
现在我想撤消上游合并。 我该怎么做?
【问题讨论】: