Posting my solution, since all others didn't work for me.
The following script retrieves the list of commits for a given REPO ("owner/repo"), traverses to the last page if necessary, and outputs the JSON object of the last (oldest) commit.
REPO="owner/repo" URL="https://api.github.com/repos/$REPO/commits" H=" -H \"Accept: application/vnd.github+json\" \ -H \"X-GitHub-Api-Version: 2022-11-28\"" response=$(curl -s -L --include $H $URL | awk 'NR > 1') # Split the output into header and json header=$(echo "$response" | awk 'BEGIN{RS="\r\n";ORS="\r\n"} /^[a-zA-Z0-9-]+:/') commits=$(echo "$response" | awk '!/^[a-zA-Z0-9-]+:/') # If paginated, get last page if [[ $header == *"link"* ]]; then # Extract the last page value link_line=$(echo "$header" | grep -i "^link:") last_page=$(echo "$link_line" | sed -n 's/.*page=\([0-9]\+\)[^0-9].*rel="last".*/\1/p') # Get last-page commits commits=$(curl -s -L $H $URL?page=$last_page) fi # Print first commit echo $commits | jq '.[-1].commit'