git:如何重置难以理解
我用 gerrit 做了一些工作,而用 gerrit 你只能得到提交的 refspec。比如:
refs/changes/01/15501/2
我该如何硬重置?
我试图表现得很好
[me@server code ((7deac0e...))]$ git reset --hard refs/changes/01/15501/2
fatal: ambiguous argument 'refs/changes/01/15501/2': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
这不是最好的错误消息,所以我再次尝试...
[me@server code ((7deac0e...))]$ git reset --hard -- refs/changes/01/15501/2
fatal: Cannot do hard reset with paths.
我不需要使用重置 --hard,但它在我的情况下效果很好。我的脚本在代码存储库中运行,但我不知道它处于什么状态。只有一个文件是可靠且不会更改的,即reset_to_gerrit脚本。
我告诉该脚本重置为某些引用规范,这将我的代码存储库放在一个我至少知道会发生什么的地方。原始状态和最终状态之间发生合并冲突的可能性非常高,硬重置应该避免所有这些。
Im doing some work with gerrit, and with gerrit you only get the refspec of a commit. Something like:
refs/changes/01/15501/2
How do I reset hard to this?
I tried to play nice
[me@server code ((7deac0e...))]$ git reset --hard refs/changes/01/15501/2
fatal: ambiguous argument 'refs/changes/01/15501/2': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions
This was not the best error message, so I tried agian...
[me@server code ((7deac0e...))]$ git reset --hard -- refs/changes/01/15501/2
fatal: Cannot do hard reset with paths.
I dont need to use reset --hard, but it would work well in my situation. My script runs in the code repo, but I have no idea what state it is in. There is only one file which is reliable and doesn't change, which is the reset_to_gerrit script.
I tell that script to reset to some refspec, and that puts my code repo in a place that i atleast know what to expect. There is a very high possibility of merge conflicts between the original and final state, and reset hard should avoid all of that.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以分两步完成。
类似:
You can do it in two steps.
Something like: