Skip to content

Instantly share code, notes, and snippets.

@aztack
Created January 19, 2024 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aztack/9403a6139164d8ca65b334af56897ed1 to your computer and use it in GitHub Desktop.
Save aztack/9403a6139164d8ca65b334af56897ed1 to your computer and use it in GitHub Desktop.
Recent Commits Log
#!/bin/bash
ancestor_branch=${1:-"origin/develop-sdk"}
# Find the latest common ancestor commit
joint_commit=$(git merge-base HEAD $ancestor_branch)
echo $joint_commit
# Get the list of commit hashes from current HEAD to the joint commit
commit_hashes=$(git rev-list --ancestry-path ${joint_commit}..HEAD)
count=0
# Iterate through the commit hashes and print the short hash and commit message
for commit_hash in $commit_hashes; do
echo "* $(git log --format='%h - %s' -n 1 $commit_hash)"
count=$((count + 1))
done
if [ $count -eq 0 ]; then
echo "No Commits Found"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment