相当于“svn update -r”的 git 是什么?
我是最近的 git 转换者。 能够使用 git-svn 将我的分支保留在本地而不干扰 svn 服务器真是太棒了。 最新版本的代码中存在一个错误。 我想确定一个有效的时间,以便我可以使用 git bisect。 我找不到正确的命令来及时返回。 谢谢。
I'm a recent git convert. It's great to be able to use git-svn to keep my branches locally without disturbing the svn server. There was a bug that existed in the latest version of the code. I wanted to establish a time when it worked so that I could use git bisect. I couldn't find the right command to move back in time. Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
这会将您当前的 HEAD 移至较早的一个版本。
这会将您当前的 HEAD 移至给定的修订版。 使用
git log
或gitk
查找您要查找的修订版本。This will move your current HEAD to one revision earlier.
This will move your current HEAD to the given revision. Use
git log
orgitk
to find the revision you’re looking for.回到最新版本(相当于:svn up),您需要更新分支,通常:
这是因为 HEAD 引用了正在签出的版本。
And getting back to latest (equivalent to: svn up), you'll need to update the branch, usually:
This is because the HEAD refers to the version that is being checked out.
似乎是更适合您正在寻找的命令
seems a more appropriate command for what you are looking for
这似乎是我想要的,这也是我认为你所要求的
This seems to do what I wanted, which is what I think you're asking for too
如果你使用 TortoiseGit 那么
If you are using TortoiseGit then
2019 年更新:正确的命令是
(例如,将文件恢复到 HEAD 父提交中的状态)
这是因为:
git checkout
太混乱了,既处理分支又处理文件。git Restore
仅...恢复文件,因为 Git 2.23(2019 年 8 月)。不需要
git checkout HEAD~ -- .
@
作为HEAD
的快捷符号。Update 2019: the proper command would be
(to, for instance, restore files at their state in HEAD parent commit)
That is because:
git checkout
is too confusing, dealing both with branches and files.git restore
only... restore files, since Git 2.23 (August 2019).No need for
git checkout HEAD~ -- .
@
as a shortcut notation forHEAD
.git 中没有与 svn update 完全相同的功能。 如果你删除了一个文件,即使你再次拉取它,它也会显示为已删除状态。 唯一的选择是签出该文件。 如果您错误地删除了多个文件并想恢复它们,您可以重命名该存储库并再次克隆它。 这就是我所做的。
There is no exact equivalent of svn update in git. If you delete a file, it will show as deleted status even if you pull it again. Only option is to checkout that file. If you have deleted multiple files by mistake and want to bring back them, You could rename that repo and clone it once again. This is what i do.