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.

#Branch

ActionCommand
rename current branchgit branch -m <new name>

#Stash

ActionCommand
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>

#Spelunking

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

ActionCommand
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
chaseonsoftware.com is powered by GatsbyJS, GitHub & Netlify.
Deployed commit of chaseonsoftware.com is 4dbe92
👋 Say Hi!