Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save pascalchevrel/d90f37895d12fc7809130924a97ded81 to your computer and use it in GitHub Desktop.

Select an option

Save pascalchevrel/d90f37895d12fc7809130924a97ded81 to your computer and use it in GitHub Desktop.
pick_no_amend for ESR relbranch
pick_no_amend() {
if [ -z "$1" ]; then
echo "Usage: pick <commit-sha>"
return 1
fi
commit="$1"
# Get the upstream tracking branch
upstream=$(git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null)
if [ -z "$upstream" ]; then
echo "🚫 Could not determine upstream branch. Are you on a tracking branch?"
return 1
fi
echo "πŸ” Trying to cherry-pick $commit..."
# Standard cherry-pick: this creates a new commit automatically
if git cherry-pick "$commit"; then
echo "βœ… Cherry-pick applied cleanly to the current branch."
echo "Staged for $upstream. You can now manually amend if needed."
git log -n 1 --oneline
else
echo "❌ Cherry-pick failed β€” aborting."
git cherry-pick --abort
return 1
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment