反转git fetch [英] reverse a git fetch
问题描述
我对git有一个透彻的理解,以及pull,fetch和merge之间的区别。我有一个遥控器,我偶尔跟踪,抓取和合并,让它说是原点/主控。我想要做的是扭转'git fetch'的行为。这听起来很愚蠢,但我想取消更新我的远程跟踪分支指向的位置,更新为旧状态,即最后一次获取之前的状态。这可能吗?
例如,可以说这是我的工作流程...
git show origin / master#shows commit abc123
git fetch#yay我得到了一些东西!
git show origin / master#显示提交def456
神秘命令到这里......
git show origin / master#shows commit abc123
有点奇怪,但我有一个crontab监视git仓库以检测何时可以提取,而且我在调试脚本时遇到了问题,该脚本根据此行为执行了一些操作。与其等待origin / master改变,我想自己改变它,以便调试我的脚本!
你想
git update-ref refs / remotes / origin / master refs / remotes / origin / master @ { 1}
update-ref
完全拼写它的更新,因为它比尊重参考约定的命令低很多。
I have a thorough understanding of git, and the difference between pull, fetch, and merge. I have a remote that I track, fetch, and merge with occasionally, let say it's origin/master. What I'm looking to do is reverse the behavior of a 'git fetch'. It sounds goofy, but I want to un-update where my remote tracking branch points, to an older state, the state right before the last fetch. Is this possible?
For example, lets say this is my workflow...
git show origin/master # shows commit abc123
git fetch # yay i got something!
git show origin/master # shows commit def456
mystery command goes here so that...
git show origin/master # shows commit abc123
It's kind of a weird thing to want, but I have a crontab that watches a git repo to detect when there's something to fetch, and I'm having issues debugging the script that performs some actions based on this behavior. Instead of waiting for origin/master to change, I'd like to change it myself so I can debug my script!
You want
git update-ref refs/remotes/origin/master refs/remotes/origin/master@{1}
update-ref
wants the full spell on the ref it's updating because it's (much) lower level than the commands that respect ref-naming conventions.
这篇关于反转git fetch的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!