How to determine if Git merge is in process

后端 未结 5 1505
轻奢々
轻奢々 2020-12-09 09:30

Is there a Git command that can be used to determine if a merge is in-process (i.e. uncommitted)? I know I can simply check for .git/MERGE_HEAD, but is this pr

5条回答
  •  星月不相逢
    2020-12-09 10:07

    Since MERGE_HEAD is only available during a merge and is also future-proof, we can simply use git rev-list -1 MERGE_HEAD (conveniently, a plumbing command) which will exit with code 128 if MERGE_HEAD is not found. Pipe stdout and stderr to /dev/null for a cleaner check. Or even better, use git rev-parse -q --verify MERGE_HEAD.

提交回复
热议问题