Skip to content

Instantly share code, notes, and snippets.

@nise-nabe
Created July 2, 2013 08:16
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 nise-nabe/5907582 to your computer and use it in GitHub Desktop.
Save nise-nabe/5907582 to your computer and use it in GitHub Desktop.
#!/bin/bash
# 第一引き数に チケット番号を与えると t-(チケット番号)に一致するブランチから
# (refs #(ブランチ名)) を持つコミットを取ってきてカレントブランチにマージする
TICKET_ID=$1
BRANCH=t-${TICKET_ID}
MERGE_TARGET=${BRANCH}-target
current_branch=`git branch | grep "*" | sed -e 's/^* \(.*\)/\1/g'`
git checkout -b ${MERGE_TARGET}
git log --grep="(refs #${TICKET_ID})" ${BRANCH} --format="%H" | git cherry-pick --stdin
git checkout ${current_branch}
git merge --no-ff ${MERGE_TARGET}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment