BugBuster1701 / docs

BugBuster Playground for Manuals, Cookbooks
Other
0 stars 0 forks source link

Umgang mit PR, lokal testen #17

Open BugBuster1701 opened 6 years ago

BugBuster1701 commented 6 years ago

in der .bashrc

#  Fetch a github pull request from <remote> and check it out locally in a branch named <remote>-pr-<pr number>
function gitpr ()
{
    if [ -z "$2" ]; then
        echo "Usage: gitpr <remote> <pr number>"
    else
        git fetch $1 pull/$2/head:$1-pr-$2 && git checkout $1-pr-$2
    fi
}
# You are on a feature branch which has been merged upstream, so checkout master, blast the old branch and sync up.
function gitpr-done ()
{
    cb=$(git rev-parse --abbrev-ref HEAD) # parse the ID of the current branch
    git checkout master
    git branch -D ${cb}
    git pull --ff-only upstream master && git push origin master --no-verify
}

oder als alias, über id PR id:

git config --global --add alias.pr '!f() { git fetch -fu ${2:-upstream} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f'

git config --global --add alias.pr-clean '!git checkout master ; git for-each-ref refs/heads/pr/* --format="%(refname)" | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done'

Pull ein Pull Request: git pr <id>

Alle PRs löschen, die mit git pr .. angelegt wurden: git pr-clean