- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
在我们的 git 仓库中,我们不小心做了一个删除我们所有文件的提交。此提交已推送到我们的中央服务器,并已被其他开发人员和构建服务器 pull 下,因此重写历史以撤消此操作并不理想。相反,我们进行了另一次回滚提交以将所有文件恢复到它们之前的状态,并在其间进行了另一次尝试的回滚提交,但不知何故只恢复了一些文件。
cc043989 Rollback commit (goes back to 4bf31def)
f5d7f10e Failed rollback commit
cd60376f Delete all files commit
4bf31def Last good commit
.
.
.
我们担心这是否会导致任何长期影响,特别是关于 merge 到/从功能分支和到/从子树 repo 。如果将来要不断进行 merge 或其他更具挑战性的事情,可能值得重写历史并手动处理构建服务器/其他开发人员存储库。
最佳答案
假设你的历史是这样的:
A --- B --- C --- D master \ E --- F topic
In commit "B", you accidentally delete all files. In commit "C", you restore all files.
When you merge the topic branch into the master branch, you will get many more merge conflicts than you would get otherwise. I suggest rewriting history as if the files were never deleted, since there is no real benefit to keeping that commit around (unless it's a very public branch).
To delete the commits,
git checkout master
git rebase -i 4bf31def
然后注释掉错误的提交:
# cc043989 Rollback commit (goes back to 4bf31def)# f5d7f10e Failed rollback commit# cd60376f Delete all files commit4bf31def Last good commit
好消息是您可以慢慢来。您可以稍后继续工作并修复历史记录,也可以现在修复它。
关于Git:删除 repo 中的所有文件然后回滚提交有任何长期影响吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14491571/
关闭。这个问题是opinion-based .它目前不接受答案。 想改进这个问题?更新问题,以便 editing this post 可以用事实和引用来回答它. 5年前关闭。 Improve this
按照目前的情况,这个问题不适合我们的问答形式。我们希望答案得到事实、引用或专业知识的支持,但这个问题可能会引发辩论、争论、投票或扩展讨论。如果您觉得这个问题可以改进并可能重新打开,visit the
我试图弄清楚如何基于 JSESSIONID cookie 为具有长期交互式用户 session 的 web 应用程序提供零停机滚动更新,这些 session 应该是粘性的。 出于这个(和其他)原因,我
这更像是一个“你能给我指出正确的方向吗”类型的问题。 基本上,我想为客户提供一种“保存”购物车的方法,也许以后可以与亲戚一起查看(这是摄影师客户的“照片篮”)。 当使用我的“照片篮”时,它会创建一个篮
我正在编写一个使用商店的网络应用程序。如果客户端在30秒内没有收到响应,则认为该请求已失效,并给出超时错误。 我正在尝试让 MongoDB 做同样的事情。例如,如果连接断开 1 分钟,驱动程序将尝试重
我多年来一直在开发和管理 Oracle 数据库应用程序,并且想学习 SQL Server。有没有人有任何书籍推荐(最好是电子版)。当然,我已经对 SQL 了如指掌,所以我想避免任何介绍性的内容,直接进
我是一名优秀的程序员,十分优秀!