组合git`continue`命令 [英] Combined git `continue` command

查看:188
本文介绍了组合git`continue`命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

各种情况下,我可能需要运行:

Variously I might need to run:


  • git rebase --continue

  • git cherry-pick --continue

  • git恢复--continue

  • git rebase --continue
  • git cherry-pick --continue
  • git revert --continue

在每种情况下,我的命令行都提醒我我处于中间状态(( rebase / cp / revert),所以对我来说很清楚,它知道哪个处于活动状态。

In each case, my command line is reminding me that I'm mid-(rebase/cp/revert) so it's clear to me that it knows which one is active.

因此,感觉上可能有一条命令 git继续它将继续执行当前正在执行的任何操作,从而节省了一些乏味的输入?

So it feels like there could conceptually be a command git continue which will continue whichever operation is currently active, thus saving some tedious typing?


  • A)是否这样做该命令已经存在(在这种情况下,它是什么,它支持什么?

  • B)如果我愿意的话,如何自己编写该命令? (也许还有别名?)

推荐答案

除了@alfunx的答案,我可能建议这样做更改:

In addition to @alfunx's answer, I might suggest this change:

代替执行 repo_path = $(git rev-parse --git-dir 2> / dev / null)因此git的返回码&日志被忽略,我将脚本更改为:

Instead of doing repo_path=$(git rev-parse --git-dir 2>/dev/null) so git's return code & log is ignored, I changed the script to this:

#!/usr/bin/env bash

repo_path=$(git rev-parse --git-dir)

if [ $? -ne 0 ]; then
    exit $?
fi

if [ -d "${repo_path}/rebase-merge" ]; then
    git rebase --continue
elif [ -d "${repo_path}/rebase-apply" ]; then
    git rebase --continue
elif [ -f "${repo_path}/MERGE_HEAD" ]; then
    git merge --continue
elif [ -f "${repo_path}/CHERRY_PICK_HEAD" ]; then
    git cherry-pick --continue
elif [ -f "${repo_path}/REVERT_HEAD" ]; then
    git revert --continue
else
    echo "No something in progress?"
fi

现在该脚本...


  1. 返回相应的退出代码(例如, 128 不是git存储库等)和git二进制本身的错误消息(例如 fatal:不是git存储库(或任何父目录):.git

  2. 如果没有任何反应,则回显没有任何进展?

  1. returns corresponding exit code(for example, 128 for not being a git repository, etc) and error message from git binary itself(like fatal: not a git repository (or any of the parent directories): .git)
  2. echo "No something in progress?" if there was nothing going on.

这篇关于组合git`continue`命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆