Last active
December 2, 2019 14:42
-
-
Save digitalronin/ca4835b0900c27697d96318221611d2e to your computer and use it in GitHub Desktop.
My git setup for faster pull-requests
This file contains 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 characters
# Hub & GHI (assumes you have homebrew installed) | |
brew install hub # https://github.com/github/hub | |
brew install ghi # https://github.com/stephencelis/ghi | |
# You will need env vars like this: EDITOR=vim, GIT_EDITOR=vim | |
# Aliases | |
alias gch='git checkout' | |
alias prune-local-branches='git branch | grep -v master | xargs git branch -d' | |
alias push-branch='git push origin $(git rev-parse --abbrev-ref HEAD)' | |
alias hpr="push-branch && hub pull-request" | |
# Script: ~/bin/get-branch | |
#!/bin/bash | |
NAME=$1 | |
git checkout -b ${NAME} origin/${NAME} | |
# Workflow | |
1. Ensure my working copy is up to date | |
gch master; git pull; prune-local-branches # I don't have an alias for this, but it's always in my history | |
2. Create a branch | |
gch -b mybranch | |
If I'm working on an existing branch, I do `get-branch otherbranch` | |
3. hack, hack, hack | |
# Ensure that the last commit message title & body is suitable as the PR title & body. | |
# Usually, I'm raising PRs for very small, simple changes, so there's probably only one commit. | |
4. Push my branch and raise a PR | |
hpr | |
# This pushes the local branch to the remote origin, then raises a PR and opens vim. Usually, I only need to save and exit. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment