gpt4 book ai didi

git - 如何还原 `git fetch upstream; git merge upstream/master` ?

转载 作者:太空狗 更新时间:2023-10-29 12:55:37 28 4
gpt4 key购买 nike

<分区>

这个问题与其他问题的不同之处在于,我想在恢复一些提交的同时保留一些提交。

这是我的设置。

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

现在我发现 upstream/master 有一个 bug,想还原,
如何回到最后一次获取/merge 上游之前的状态?

编辑。

假设

  1. I merged upstream
  2. I merged what a team member pushed to origin/master(Personal)

现在我想撤消步骤 1。

git reset --hard commit_sha_of_one_prior_the_merge_1

(Although finding the sha is not easy. git log shows a lot of commit sha's of upstream, so it's not easy to find commit-sha-of_one_prior_the_merge_1 which is not of upstream but of origin/master)

如何保持步骤 2 merge ?

假设一个稍微复杂一点的场景

  1. I merged upstream
  2. I merged what another team member pushed to Personal
  3. I also pushed my work to Personal

现在我想撤消上游 merge 。我该怎么做?

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com