Git Commands

I use git on a daily basis and this is a list of commands that I use frequently or infrequently enough to need a reminder of how to do them.


rename current branchgit branch -m <new name>


diff latest stash against current branchgit stash show -p
diff specific stash against current branchgit stash show -p stash@{<StashNumber>}
show only the filenames of a stashgit stash show --name-only stash@{<StashNumber>}
only apply changes from a specific file in a stashgit checkout stash@{<StashNumber} -- <path/to/file>


I call it "spelunking" because a lot of times I find myself digging through the history of code.

Find commits where a line changed in a specific filegit log -S <string> <path/to/file>
Enjoy this article? Share it on Twitter!
View the source on GitHub is powered by GatsbyJS, GitHub & Netlify.
Deployed commit of is 4dbe92
👋 Say Hi!