git reflog 使用_使用git reflog修复基准问题

git reflog 使用

My git jedi skills aren't top class yet but I'm learning how to use the force.  I recently rebased  a pull request, only to find that it added about two dozen more commits, thus my branch was hosed.  After a bit of research, I found git reflog, a utility to view previous actions and get the information I needed to fix my rebase.

我的git jedi技能还不是一流,但是我正在学习如何使用力量。 我最近重新建立了一个拉取请求的基础,却发现它增加了大约两打提交,因此我的分支被关闭了。 经过一番研究,我找到了git reflog ,该实用程序可查看以前的操作并获取修复基准所需的信息。

When you execute git reflog, you get a massive list of your previous actions.  The list will look like:

当您执行git reflog ,您会得到以前操作的大量列表。 该列表如下所示:

d2ed542 HEAD@{0}: checkout: moving from badges-ui-rebase to sign-in-width
fd69f6e HEAD@{1}: rebase -i (finish): returning to refs/heads/badges-ui-rebase
fd69f6e HEAD@{2}: rebase -i (squash): First pass at badge improvements
f79a769 HEAD@{3}: checkout: moving from badges-ui-rebase to f79a769
552473c HEAD@{4}: commit: First pass at badge improvements
f79a769 HEAD@{5}: rebase -i (finish): returning to refs/heads/badges-ui-rebase
f79a769 HEAD@{6}: commit: More
e9227ed HEAD@{7}: checkout: moving from badges-ui-rebase to e9227ed257ea1966fffc
5f0d862 HEAD@{8}: checkout: moving from master to badges-ui-rebase
e9227ed HEAD@{9}: pull mozilla master: Fast-forward
bf9084a HEAD@{10}: checkout: moving from sign-in-width to master
d2ed542 HEAD@{11}: rebase -i (finish): returning to refs/heads/sign-in-width
d2ed542 HEAD@{12}: checkout: moving from sign-in-width to d2ed542
d2ed542 HEAD@{13}: checkout: moving from use-strict to sign-in-width
4f3443d HEAD@{14}: rebase -i (finish): returning to refs/heads/use-strict
4f3443d HEAD@{15}: rebase -i (squash): Adding 'use strict' to JS files
294c376 HEAD@{16}: rebase -i (pick): Adding 'use strict' to JS files
bf9084a HEAD@{17}: checkout: moving from use-strict to bf9084ae49c269ce85651b829
824920e HEAD@{18}: commit: fix
47f9969 HEAD@{19}: checkout: moving from badges-ui-rebase to use-strict
5f0d862 HEAD@{20}: rebase -i (finish): returning to refs/heads/badges-ui-rebase
5f0d862 HEAD@{21}: rebase -i (squash): First pass at badge improvements
95ae782 HEAD@{22}: checkout: moving from badges-ui-rebase to 95ae782
a75a292 HEAD@{23}: commit: Fix else error
#....

When I found the commit I wanted to roll back to, I used git reset to do so:

当我找到要回滚的提交时,我使用git reset这样做:


# git reset --hard HEAD@{##}
git reset --hard HEAD@{87}


Awesome!  Instead of needing to start over with my changes, I was able to retry my rebase and get things fixed.  git reflog can be a massive time-saver!

太棒了! 无需重新进行更改,我可以重试调整基准并修复问题。 git reflog可以节省大量时间!

翻译自: https://davidwalsh.name/git-reflog-fix-rebase-problems

git reflog 使用

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值