Sometimes I want a Git commit message without the leading indentation added by “git show” (for example, if I want to copy it and paste it somewhere else). This command gives me this output.
git alias
Git Squash Back To
Often in my work, I’ll create a number of commits before I craft my correct solution. Having these missteps in separate commits doesn’t provide any real value and adds noise so I’ll often squash these commits into a single commit. Historically, I’ve used a Git interactive rebase to do this but as I was reminded on Mastodon, it seems like there should be a quicker way, so I’ve created a Git alias, “git squashbackto”, to do this.
Git Alias Tab Completion Not Working
After setting up new machine I noticed my Git alias tab completion had stopped working. I created this blog post to document how I tracked down this issue and resolved it.
Replace Local Git Branch with Branch on GitHub
There are times when I want to dispose of my local branch and replace it with the version on GitHub (the upstream version). For example, when I’m reviewing a teammate’s pull request and they rewrite history (e.g. perform a rebase or amend a commit), I don’t have any work on that branch and I only want their updated version.
Is Git Branch Up to Date
I often want to determine if my current Git branch is up to date with some other branch. One specific scenario is when I want to check if my current “feat/” branch is up to date with “main” (i.e. no new commits have been introduced in “main” that aren’t in “feat/”).
Git Alias Can Not Change Directory
I wanted to add a Git alias that does a “git clone” and then “cd” to change into the new directory. However, while the “git clone” worked fine, the directory change did not. It turns out you can NOT change directories from within a Git alias.
My Most Valuable Git Aliases are Shell Aliases
While Git supports aliases and I am a big fan of Git aliases, (e.g. ‘git lg’), the most valuable to me (and most used) aliases are shell aliases (e.g. ‘gc’ for ‘git commit’).
Git delete remote branch
This is the command I run when I want to delete a branch named “chore/fix-typo” from the default remote (which is named “origin”): git push origin –delete chore/fix-typo
git alias tab completion for functions
When creating a Git alias that points to a function, sometimes Git provides the wrong tab completion by default (e.g. filename completion instead of branch name completion). This is how we can tell Git, which type of completion to use.
Git Alias Open Pull Request on GitHub
I want to be able to type “git gh-open-github” and have my browser open to the GitHub URL to create a Pull Request (PR) for my current branch on the current project I’m working on. Here is how I built this.
