git rebase真的很老
我正在尝试撤消一项非常古老的提交,该提交已经被推到遥控器上。 我环顾四周,以为git rebase
可能是最好的解决方案。 因此,我运行了代码:
git rebase -i <commit-id>
然后编辑:
pick <commit-id> <commit-title>
drop <commit-id> <commit-title> <- the commit I want to delete
pick <commit-id> <commit-title>
然后尝试使用:WQ
应用此代码。但是,这引发了很多合并冲突(该提交大约是半年的)。
我要撤消该提交的原因是因为我不小心添加了一个带有凭据的文件,我不应该与其他合作者分享。
因此,我唯一要撤消的是遥控器上文件的“创建”。git rebase
最好的方法吗?
如果是这样 我宁愿不要以错误的方式偶然地合并冲突。
我试图删除的提交也不应与未来的提交造成任何冲突。我尝试运行git rebase
而不会丢弃提交,但合并冲突仍然弹出。
I am trying to undo a really old commit that has already been pushed to the remote.
I looked around and thought that git rebase
was probably the best solution.
so I ran the code:
git rebase -i <commit-id>
then edited:
pick <commit-id> <commit-title>
drop <commit-id> <commit-title> <- the commit I want to delete
pick <commit-id> <commit-title>
Then tried applying this with :wq
. This however triggered a LOT of merge conflicts (the commit is about half a year old).
The reason I want to undo the commit is because I accidentally added a file with credentials on it that I should not share with other collaborators.
So the only thing I want to undo is the "creation" of the file on the remote.
Is git rebase
the best approach?
if so is there a way not to trigger all the merge conflicts (merge them just like before)?
I would rather not accidentally merge a conflict in the wrong way.
Also the commit I am trying to delete should not cause any conflicts with future commits. I tried running git rebase
without dropping the commit but the merge conflicts still popped up.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
感谢@elpiekay!
git filter-repo
设法完成了工作有关完整详细信息,请查看在这里。
我首先尝试使用
bfg
,但是我遇到了一些问题,因此我转到git filter-repo
。git filter-repo
git clone
)。此步骤是因为
git-filter-repo
警报以在刚克隆的仓库中运行该命令。.gitignore
。如果还没有,请确保在其他地方保存凭据。
那应该解决问题!祝你好运!
Thanks to @ElpieKay!
git filter-repo
managed to do its jobFor full details look here.
I first tried to use
BFG
, but I had some issues so I moved on togit filter-repo
.git filter-repo
git clone
).This step was because
git-filter-repo
alerted to run the command in a freshly cloned repo..gitignore
.Make sure to save the credentials elsewhere if you haven't already.
And that should do the trick! Good Luck!