Combined git `continue` command

前端 未结 2 1145
不知归路
不知归路 2021-01-19 05:10

Variously I might need to run:

  • git rebase --continue
  • git cherry-pick --continue
  • git revert --continue<
2条回答
  •  孤街浪徒
    2021-01-19 05:19

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

    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
    

    Now this script...

    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.

提交回复
热议问题