Skip to main content

5 posts tagged with "git"

View All Tags

Quick GitHub PR Creation

Add the following to your ~/.bashrc or ~/.zshrc:

alias ghpr='git push && gh pr create --fill'

Now just run ghpr after you've committed, and now you have a PR!

My Opinionated Git Conventions

My (very) opinionated Git conventions. If you follow these, you will be much less likely to create messed up git histories, and your git setup will make much more sense.

Setup and Use Git Worktree

Clone a repo with worktrees setup from the start:

mkdir <repo-name>
cd <repo-name>
git clone --bare --filter=blob:none <git-url>
cd <repo-name>.git

Some options to help your sanity:

# always prune on fetch
git config fetch.prune true
# allow `git fetch origin <branch-name>` to work as expected (create a remote ref)
git config remote.origin.fetch '+refs/heads/*:refs/remotes/origin/*'

To create a new branch:

git worktree add ../<branch-name>
cd ../<branch-name>

To copy a remote branch (note that this will only work with the above fetch config set):

git fetch origin <branch-name>
git worktree add ../<branch-name>
cd ../<branch-name>

To create a new branch based on a remote branch:

git worktree add ../<branch-name> -b <branch-name> --no-track origin/dev
cd ../<branch-name>