Last active
June 27, 2025 08:11
-
-
Save jhnns/d654d9d6da6d3b749986 to your computer and use it in GitHub Desktop.
Revisions
-
jhnns revised this gist
Sep 24, 2015 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -23,7 +23,7 @@ if [[ $id = "clean" ]]; then git branch -D ${ref#refs/heads/} done exit 0 elif [[ $id =~ ^(https?://[^/]+/(.+))/pull/([0-9]+).*$ ]]; then remote=${BASH_REMATCH[1]}.git id=${BASH_REMATCH[3]} branch=pr/${BASH_REMATCH[2]}/$id -
jhnns revised this gist
Sep 24, 2015 . 1 changed file with 2 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -32,6 +32,6 @@ else fi echo "git fetch -fu $remote pull/$id/head:$branch" git fetch -fu $remote pull/$id/head:$branch git checkout $branch -
jhnns revised this gist
Sep 24, 2015 . 1 changed file with 11 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,12 +1,13 @@ #!/bin/bash if [ -z "$1" ]; then echo "Usage: git pr [clean] [<remote>] <id-or-url>" echo "" echo "Examples:" echo "git pr 42 --> git fetch origin pull/42/head:pr/origin/42" echo "git pr upstream 42 --> git fetch upstream pull/42/head:pr/upstream/42" echo "git pr https://github.com/peerigon/phridge/pull/1 --> git fetch https://github.com/peerigon/phridge.git pull/1/head:pr/peerigon/phridge/1" echo "git pr clean --> Deletes all branches that match pr/*/* and pr/*/*/*" exit 1 elif [ -z "$2" ]; then id=$1 @@ -16,7 +17,13 @@ else remote=$1 fi if [[ $id = "clean" ]]; then git for-each-ref refs/heads/pr/*/* refs/heads/pr/*/*/* --format='%(refname)' | while read ref; do echo "git branch -D ${ref#refs/heads/}" git branch -D ${ref#refs/heads/} done exit 0 elif [[ $id =~ ^(https?://[^/]+/(.+))/pull/([0-9]+)$ ]]; then remote=${BASH_REMATCH[1]}.git id=${BASH_REMATCH[3]} branch=pr/${BASH_REMATCH[2]}/$id @@ -26,4 +33,5 @@ fi echo "git fetch $remote pull/$id/head:$branch" git fetch $remote pull/$id/head:$branch git checkout $branch -
jhnns revised this gist
Sep 24, 2015 . No changes.There are no files selected for viewing
-
jhnns created this gist
Sep 24, 2015 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ #!/bin/bash if [ -z "$1" ]; then echo "Usage: git pr [<remote>] <id-or-url>" echo "" echo "Examples:" echo "git pr 42 --> git fetch origin pull/42/head:pr/origin/42" echo "git pr upstream 42 --> git fetch upstream pull/42/head:pr/upstream/42" echo "git pr https://github.com/peerigon/phridge/pull/1 --> git fetch https://github.com/peerigon/phridge.git pull/1/head:pr/peerigon/phridge/1" exit 1 elif [ -z "$2" ]; then id=$1 remote=origin else id=$2 remote=$1 fi if [[ $id =~ ^(https?://[^/]+/(.+))/pull/([0-9]+)$ ]]; then remote=${BASH_REMATCH[1]}.git id=${BASH_REMATCH[3]} branch=pr/${BASH_REMATCH[2]}/$id else branch=pr/$remote/$id fi echo "git fetch $remote pull/$id/head:$branch" git fetch $remote pull/$id/head:$branch