Skip to content

Instantly share code, notes, and snippets.

@MizoTake
Last active September 26, 2024 07:58
Show Gist options
  • Select an option

  • Save MizoTake/efb9f7594f883f2fa759f9cc298a9183 to your computer and use it in GitHub Desktop.

Select an option

Save MizoTake/efb9f7594f883f2fa759f9cc298a9183 to your computer and use it in GitHub Desktop.
cherry-picks
#!/bin/bash
# チェリーピックするコミットハッシュを格納したファイル
commit_file="commits.txt"
# ファイルが存在するかチェック
if [ ! -f "$commit_file" ]; then
echo "Commit file not found: $commit_file"
exit 1
fi
# コミットハッシュごとにループしてチェリーピック
while IFS= read -r commit_hash
do
# コミットハッシュから改行や空白を取り除く
commit_hash=$(echo "$commit_hash" | tr -d '\n\r' | xargs)
# 空行を無視
if [ -z "$commit_hash" ]; then
continue
fi
echo "Cherry-picking commit: $commit_hash"
git cherry-pick "$commit_hash"
# チェリーピックが失敗した場合、処理を中断
if [ $? -ne 0 ]; then
echo "Cherry-pick failed for commit: $commit_hash"
exit 1
fi
done < "$commit_file"
echo "All commits cherry-picked successfully."
// commit hash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment