能够查看远程的reflog吗?也就是说,我想知道在另一台远程机器上运行git reflog
的输出结果。
请注意,我不是在询问远程跟踪分支(如origin/master
)的reflog;我问的是在另一台机器上reflog
的输出结果。
能够查看远程的reflog吗?也就是说,我想知道在另一台远程机器上运行git reflog
的输出结果。
请注意,我不是在询问远程跟踪分支(如origin/master
)的reflog;我问的是在另一台机器上reflog
的输出结果。
如果远程机器是一个github仓库的话,
首先使用Github的Events API来检索提交的SHA。
curl https://api.github.com/repos/<owner>/<repo>/events
确定那个不再存在于任何分支中的孤立提交的SHA。
接下来,使用Github的Refs API来创建一个指向孤立提交的新分支。
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"ref":"refs/heads/D-commit", "sha":"<orphan-commit-id>"}' https://api.github.com/repos/<owner>/<repo>/git/refs
在上述命令中用步骤2中确定的SHA替换<orphan-commit-id>
。
git fetch
命令拉取到本地仓库中。gh api repos/<owner>/<repo>/git/refs -X POST -F ref=refs/heads/D-commit -F sha=<orphan-commit-id>
查看本文以获取一个实际示例。"message": "Not Found"
的错误信息,这意味着你需要进行身份验证,例如通过传递一个access_token查询字符串。 - Andy Haydengit update-ref -m msg <name> <target>
命令时,更新都被记录在本地:.git/logs/<name>
会添加一行内容。$ git update-ref -m foo HEAD HEAD^
$ tail -1 .git/logs/HEAD
2418b6ba8fd0289933c9351260a272b8e410867f 8d945134b0cead535d66af29c8eb4228b5dc3763 [redacted] <[redacted]> 1334106483 -0600 foo
在这种情况下,在消息之前的东西(在本例中为foo
)不是空格而是tab,我为了在stackoverflow上展示而将其展开。从概念上讲,移动分支指针的所有其他操作都会调用git update-ref
来完成它(有些是shell脚本,实际上就是这样做的,而另一些则只是调用执行所有文件更新的C代码)...而.git/logs
中的所有内容都构成了reflog。
如果底层的git://和/或ssh://协议中有让您访问reflog的功能,那么这将起作用,但据我所知并没有这样的功能。
git push --force-with-lease
https://thoughtbot.com/blog/git-push-force-with-lease - Othmane El Kesrigit reflog refs/remotes/<remote name>/<branch name>
所以如果你的远程仓库叫做“origin”,而你的分支叫做“turtles”:
git reflog refs/remotes/origin/turtles
refs/remotes/*
。 - Guildensternrefs/remotes/*
。 - Guildenstern