diff --git a/git/gitconfig b/git/gitconfig index 5ca7472..a238783 100644 --- a/git/gitconfig +++ b/git/gitconfig @@ -28,8 +28,10 @@ ra = !git r --all l = "!source ~/.githelpers && pretty_git_log" la = !git l --all + sync = "!source ~/.githelpers && sync_to_remote" todo = grep --heading --break --ignore-case -e ' FIX: *' -e ' TODO: *' + pr = "!source ~/.githelpers && get_pr" [merge] tool = vimdiff ff = false diff --git a/git/githelpers b/git/githelpers index c84a81d..23224f6 100644 --- a/git/githelpers +++ b/git/githelpers @@ -40,3 +40,17 @@ pretty_git_log() { less -FXRS } +sync_to_remote() { + REMOTE=$1 + : ${REMOTE:="upstream"} + BRANCH=`git rev-parse --abbrev-ref HEAD` + git fetch upstream + git merge --ff-only ${REMOTE}/${BRANCH}; +} + +get_pr() { + REMOTE=$2 + : ${REMOTE:="upstream"} + git fetch ${REMOTE} pull/${1}/head:pr/${1} + git checkout pr/${1} +} \ No newline at end of file