Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/295.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在git中恢复远程操作的错误获取_Git_Git Fetch - Fatal编程技术网

如何在git中恢复远程操作的错误获取

如何在git中恢复远程操作的错误获取,git,git-fetch,Git,Git Fetch,我有一些git回购协议和很多远程设备,一些远程分支是唯一的,我没有本地跟踪分支 今天我在更改远程url时犯了错误(我使用了remote1而不是remote2) 在git fetch之后--all我的remote1被重写(我看到+在commit sha之前) 这很糟糕,因为我现在无法访问remote1,而且我无法修改url并获取 在错误获取之后,是否可以从我的本地repo还原remote1分支?Git会在reflog中记录引用(如分支提示和远程分支提示)发生的所有事情,您必须深入其中才能找到远程的

我有一些git回购协议和很多远程设备,一些远程分支是唯一的,我没有本地跟踪分支

今天我在更改远程url时犯了错误(我使用了remote1而不是remote2)

在git fetch之后--all我的remote1被重写(我看到+在commit sha之前)

这很糟糕,因为我现在无法访问remote1,而且我无法修改url并获取


在错误获取之后,是否可以从我的本地repo还原remote1分支?

Git会在reflog中记录引用(如分支提示和远程分支提示)发生的所有事情,您必须深入其中才能找到远程的上一个SHA

要搜索git reflog,请输入
git reflog
,然后搜索上次提到的(refs/remotes/remote/branch)。它会给你一个SHA

然后,您可以通过运行

git update-ref refs/remotes/remote1/branch

编辑您可以尝试查找悬空提交。

Git在reflog中记录引用(如分支提示和远程分支提示)发生的所有事情,您必须深入其中才能找到远程的上一个SHA

要搜索git reflog,请输入
git reflog
,然后搜索上次提到的(refs/remotes/remote/branch)。它会给你一个SHA

然后,您可以通过运行

git update-ref refs/remotes/remote1/branch

编辑您可以尝试查找悬空提交。

我理解这个想法,但在reflog中找不到有关remote1/branch的任何信息。有很多垃圾,比如“结帐:移动”和“合并:快进”,但没什么有趣的。@KorjavinIvan:对不起,没有线索。。。您可以尝试使用Yep git查找悬空提交。fsck就是答案。非常感谢。我理解这个想法,但在reflog中找不到关于remote1/branch的任何信息。有很多垃圾,比如“结帐:移动”和“合并:快进”,但没什么有趣的。@KorjavinIvan:对不起,没有线索。。。您可以尝试使用Yep git查找悬空提交。fsck就是答案。非常感谢。