我使用还原做了一些非常愚蠢的事情,而且我不知道如何正确地修复它。 我会尝试清楚解释。
我想在项目存储库中添加foo
,bar
和baz
。
由于某些原因(因为我是个白痴),我做了以下一些混乱
(其中" -xxx_commit"是" + xxx-commit"的git-revert:)
foo_branch
+foo_commit 1
bar_branch
+foo_commit 1
+bar_commit 2
-foo_commit 3
baz_branch
+foo_commit 1
+bar_commit 2
-foo_commit 3
-bar_commit 4
+baz_commit 5
然后,foo_branch
和baz_branch
已合并到上游存储库中......
因此:
upstream/master
+foo_commit 1
+foo_commit 1
+bar_commit 2
-foo_commit 3
-bar_commit 4
+baz_commit 5
现在,foo
已被添加,然后被删除,我无法合并或重新定位upstream/master
bar_branch
,因为它会自行恢复......
你知道清理这个烂摊子吗?
是否有git-idiot
命令或类似的东西?
答案 0 :(得分:2)
如果还原,在master -foo_commit 3和-bar_commit 4(foo和bar的恢复)中,还原foo和bar?你应该以你的回购中的foo,baz和bar结束。 这里有一个例子的情况(如果我做对了):
ghislain@debian: /tmp/git-test (master) > git history * a3ca029 (HEAD, master) - Merge branch 'baz_branch' (2 seconds ago) |\ | * db33181 (baz_branch) - baz_commit (17 seconds ago) | * 618b704 - Revert "bar_commit" (32 seconds ago) | * 672b77c (bar_branch) - Revert "foo commit" (51 seconds ago) | * 06230db - bar_commit (62 seconds ago) * | 90ba017 - Merge branch 'foo_branch' (7 seconds ago) |\ \ | |/ | * 60ea014 (foo_branch) - foo commit (79 seconds ago) |/ * 0b863fe - initial (4 minutes ago) ghislain@debian: /tmp/git-test (master) > git merge --no-ff bar_branch Already up-to-date. ghislain@debian: /tmp/git-test (master) > ll total 0 -rw-r--r-- 1 ghislain fuse 0 Jul 23 15:18 baz -rw-r--r-- 1 ghislain fuse 0 Jul 23 15:14 README ghislain@debian: /tmp/git-test (master) > git revert 672b77c 618b704 [master 88af7cd] Revert "Revert "foo commit"" 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 foo :[master d2cf0a3] Revert "Revert "bar_commit"" 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 bar ghislain@debian: /tmp/git-test (master) > ll total 0 -rw-r--r-- 1 ghislain fuse 0 Jul 23 16:37 bar -rw-r--r-- 1 ghislain fuse 0 Jul 23 15:18 baz -rw-r--r-- 1 ghislain fuse 0 Jul 23 16:37 foo -rw-r--r-- 1 ghislain fuse 0 Jul 23 15:14 README