Git Commands

A couple of handy commands to take control of your source!

Git Commands
Photo by Yancy Min / Unsplash
🖋️
git log -S search_term [filename]

Search for text in git logs - handy to find out when a specific line of code was changed!

further reading...

git log -S "thing.callSomething(withVar)" .\File.cs
🖋️
git clean -xdf

The git clean command is used to remove unwanted files from your working directory - this could include removing temporary build artifacts or merge conflict files.

It erases each and every file in your git directory which is NOT part of your repository. All additional files, such as the ones listed in your .gitignore, will be removed.

further reading...

git clean -xdf
🖋️
git blame "path/to/file" | grep "text you're interested in"

The git blame command shows what revision and author last modified each line of a file.

Can use grep to find a specific piece of text, or pass additional info like line numbers.

further reading...

git blame README.md -L 3,5