我推送代码时如何回滚到较旧的提交?

时间:2016-09-22 10:45:34

标签: git git-push

我正在处理两个不同的分支AB,我有一个prod分支MASTER,我创建了一个新的分支C,结合了AB

我不小心将C推到了MASTER,现在我不知道如何回到prod状态,因为有太多的提交。

commit 92e15c92d543e436bd5804ab6c9
Author: user_A
Date:   Thu Sep 22 15:51:47 2016 +0530

    fixing user report

commit dfd1f4e0d56f50d263d6e
Merge: 1a6bc83 f9b0a35
Author: user_A
Date:   Thu Sep 22 15:47:01 2016 +0530

    Merge branch 'MASTER' of git_repo_branch into B

commit 1a6bc83c55cf1b3d7f88d
Author: user_A
Date:   Thu Sep 22 15:46:46 2016 +0530

    fixing user report

commit dd11a998f380c70b579d2a0
Author: user_A
Date:   Thu Sep 22 13:09:29 2016 +0530

    fixing rake task

commit c194f900e58f93b0a06ed
Author: user_A
Date:   Thu Sep 22 13:08:40 2016 +0530

    fixing rake task

commit f9b0a35430d29826622d95
Author: user_B
Date:   Thu Sep 22 11:36:50 2016 +0530

    jobs save as draft fix

commit 3a1b233b365a96886e2d73
Merge: 2eac96c c4f61b1
Author: user_A
Date:   Thu Sep 22 11:35:20 2016 +0530

    Merge branch 'A' into B

commit dfd1f4e0d56f50d263d6eb5
Merge: 1a6bc83 f9b0a35
Author: user_A
Date:   Thu Sep 22 15:47:01 2016 +0530

    Merge branch 'MASTER' of git_repo_branch into B

commit 1a6bc83c55cf1b3d7f88da697411d5c5acb5b9c4
Author: user_A
Date:   Thu Sep 22 15:46:46 2016 +0530

    fixing user report

commit dd11a998f380c70b579d2a0b
Author: user_A
Date:   Thu Sep 22 13:09:29 2016 +0530

    fixing rake task

commit c194f900e58f93b0a06eddf8
Author: user_A
Date:   Thu Sep 22 13:08:40 2016 +0530

    fixing rake task

commit f9b0a35430d29826622d9
Author: user_B
Date:   Thu Sep 22 11:36:50 2016 +0530

    jobs save as draft fix

commit 3a1b233b365a96886e2d7334
Merge: 2eac96c c4f61b1
Author: user_A
Date:   Thu Sep 22 11:35:20 2016 +0530

    Merge branch 'A' into B

commit c4f61b151c28ce36b0c7987276df90ddc91c84fc
Merge: 0f18c62 fb70961
Author: user_A
Date:   Thu Sep 22 11:35:04 2016 +0530

commit f9b0a35430d29826622d950b9e149c05cf937644
Author: user_B
Date:   Thu Sep 22 11:36:50 2016 +0530

    jobs save as draft fix

commit 3a1b233b365a96886e2d73
Merge: 2eac96c c4f61b1
Author: user_A
Date:   Thu Sep 22 11:35:20 2016 +0530

Author: user_A
Date:   Thu Sep 22 13:08:40 2016 +0530

    fixing rake task

commit f9b0a35430d29826622d950b9
Author: user_B
Date:   Thu Sep 22 11:36:50 2016 +0530

    jobs save as draft fix

commit 3a1b233b365a96886e2d733403fa66e8dd4992fc
Merge: 2eac96c c4f61b1
Author: user_A
Date:   Thu Sep 22 11:35:20 2016 +0530

    Merge branch 'A' into B

commit c4f61b151c28ce36b0c79872
Merge: 0f18c62 fb70961
Author: user_A
Date:   Thu Sep 22 11:35:04 2016 +0530

    Merge branch 'MASTER' of git_repo_branch into A

commit 0f18c62cbae31b5f6a76d
Author: user_A
Date:   Thu Sep 22 11:34:06 2016 +0530

    changing name to slug

commit 56fbcd2e544d97aef2bb
Author: user_A
Date:   Thu Sep 22 11:28:38 2016 +0530

    changing name to slug

commit 2eac96cc7c56aa1f3bda29b9257e045c3b923dfe
Merge: 0caa9d1 f794d6e
Author: user_A
Date:   Wed Sep 21 17:08:37 2016 +0530

    added A_to_B

commit 0caa9d1076ee83d53b0586f2e7cd79f16320ac0e
Merge: 5df1d6d fb70961
Author: user_A
Date:   Wed Sep 21 15:49:40 2016 +0530

    removing conflict

commit f794d6ee277f0ba5964dc534c05cfe234761e569
Author: user_A
Date:   Wed Sep 21 15:41:21 2016 +0530

    fixing users name

commit cc97e8749cccdfee47bb67bbe6470639afbd1d28
Author: user_A
Date:   Wed Sep 21 15:15:53 2016 +0530

    raising 404 if user not found

commit fb709619d0a9f39c6b2a2c7b5a08c47835970c0f
Author: user_B
Date:   Wed Sep 21 12:44:32 2016 +0530

    usercount yopwise report

commit a332dfe71fd7de74eadcce43337699bb4205e29d
Author: user_A
Date:   Tue Sep 20 17:29:35 2016 +0530

    code error fix

commit 323fa5ed6b2002a664adcfc1ae6b295198258fe2
Author: user_A
Date:   Tue Sep 20 17:22:50 2016 +0530

    limiting 

commit ea94a85e1ad259162d4a883cda08635697012602
Author: user_A
Date:   Tue Sep 20 17:15:17 2016 +0530

1 个答案:

答案 0 :(得分:1)

您可以回滚到先前的提交,请查看git log以获取更多详细信息, 然后强制你的提交到主分支:

git push origin +<shaofcommit>:master

+会强制提交,或者您也可以使用-f选项。