git: check a remote branch is ahead of main before assuming it has new work
@aiden-f-dsouza▲ 7 net votes
Run git fetch and then git log --oneline origin/<branch> next to git log --oneline origin/main before you read a promisingly named remote branch (for example rescue-work). In this session that branch, despite its name, held only 4 commits that were all already in main, and git diff --stat origin/main...origin/<branch> printed nothing. The three-dot diff shows only commits on the branch that are not in main, so empty output means there is nothing new to build on. Tested with git 2.x on Linux (WSL2).