【问题标题】:Git Reset after multiple bad rebasing after push推送后多次错误变基后 Git 重置
【发布时间】:2019-07-30 10:18:33
【问题描述】:

我是新来的,所以我会尽力做到最好。

我的 git 分支遇到了一些问题。

确实,我正在开发一个名为“myName”的分支。我正在开发一项需要很长时间才能开发的新功能。这就是为什么我经常做'git rebase master'。但是,我在进行变基之前推送了我的提交。

所以我的分支和远程分支已经分道扬镳了。我拉动更改,然后继续开发。 2 到 3 次后,我意识到这有点破坏了我的 git 历史。所以我想知道如何清理我的历史记录,或者在一个新的分支上获取这个分支的代码,这将是一个新的开始,而不保留这个糟糕的历史记录。

这是我的历史预览:

1af3418 (HEAD -> dashboards) Add of the mapChart & new start
a18d6b9 Add of the mapChart with real Data
cd29620 Adaptation of the LineChart component and the Dashboards page after setting the backend
71d288e Add of LineCharts Components and display of 1st LineChart component with Fake Data
ca33ac3 WA-446 Check undefined oauth
d4124bb Add of the PieChart Component 1st charts on Dashboards page
83db3e8 Test of rebase command
f474a41 Test of rebase command
3c3d0a4 Fix undefined ClipLoader
1297024 Update react to 16.8.3
ad83624 Test of rebase command
8f145a3 Test of rebase command
ec363bf Test to add dahsboard page
bc71ead Fix undefined ClipLoader
40cc4ff Update react to 16.8.3

如果您需要更多信息,请告诉我,感谢您的帮助。

【问题讨论】:

    标签: git push rebase history


    【解决方案1】:

    使用git reset --soft hash_you_want_to_replacegit reset --mixed hash_you_want_to_replace(默认)并进行新的提交。

    您将使用工作目录的最后更改在您选择的哈希处创建一个新提交,并且您将在您选择的提交之后删除提交(首先确保备份)

    所以使用git reset ec363bf,您将替换Test to add dahsboard page 并删除所有其他提交,直到HEAD

    【讨论】:

    • 非常感谢您的回答。好的,使用此解决方案,我丢失了分支的逻辑历史记录。但是我没有找到更好的解决方案,它让我有一个干净的历史。所以,除非有人有一个神奇的提议,否则我会接受你的。再次感谢。
    • 我不确定你真正想要做什么。如果要删除所有提交和日志历史记录,请删除 .git 文件夹并从 git init 重新开始。
    猜你喜欢
    • 2019-10-01
    • 2018-08-13
    • 2019-11-30
    • 1970-01-01
    • 2021-08-12
    • 1970-01-01
    • 1970-01-01
    • 2020-10-14
    • 2012-07-23
    相关资源
    最近更新 更多