Skip to content

Instantly share code, notes, and snippets.

@carstene1ns
Last active May 7, 2025 21:07
Get all commits of the current branch since creation from another branch

Usage

Show all commits the current feature branch has:

$ git show -s $(./git-branch-commits.sh)

Cherry-Pick all commits the specific pull request (checked out as branch) has:

$ git cherry-pick $(./git-branch-commits.sh pr/2215)
#!/bin/bash
branch=$1
base=${2:-master}
if [ -z "$branch" ]; then
branch=$(git branch --show-current)
if [ -z "$branch" ]; then
echo "Provide a branch!"
exit 1
fi
fi
git rev-list --reverse $branch --not $(git rev-list $base ^$branch --merges | tail -1)^
@Ghabry
Copy link

Ghabry commented May 7, 2025

maybe add this directly into the Player repo?
We don't do this stable/patch release stuff that often and I always waste 10 minutes to remember where the script was :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment