steffen-wirth
1/6/2016 - 10:43 AM

good bash aliases

good bash aliases


https://gist.github.com/arriolac/7794655

### git ###

# Deletes all branches that are already merged into the current branch
alias gitrmbr='git branch --merged | grep -v "\*" | xargs -n 1 git branch -d'

# Creates a pull request on GitHub for the currently checked out branch
function pr () {
  if ["$1" == ""]
  then
      echo "Please provide the name of the branch to create a pull request against."
  else
      local repo=`git remote -v | grep -m 1 "(push)" | sed -e "s/.*github.com[:/]\(.*\)\.git.*/\1/"`
      local branch=`git name-rev --name-only HEAD`
      echo "... creating pull request for branch \"$branch\" in \"$repo\""
      open https://github.com/$repo/compare/$1...$branch
  fi
}

# Fetches a pull request from GitHub given the pull request number
function fpr () {
  echo git fetch origin pull/$1/head:pr$1
  git fetch origin pull/$1/head:pr$1
  echo git checkout pr$1
  git checkout pr$1
}