Check if a git branch is ahead of another using a script
问题 I have branch1 and branch2 and I want some sort of: git branch1 isahead branch2 That will show if branch1 has commits that branch2 doesn't have (and possibly specify those commits too). I can't check diff cause branch2 is ahead of branch1 (has commits that branch1 doesn't have). Is there a way? I looked through git diff and couldn't find anything 回答1: You can use git log branch2..branch1 If branch1 has no commit ahead of branch2 , output will be empty. You can also use git rev-list --count