git log -S (Pickaxe search)
Find commits where this string was added or removed:
git log -S "fetchW3w" --oneline
git log -G (Regex search)
More flexible pattern matching:
git log -G "fetchW3w" --oneline -p
The -p flag shows the actual diff.
git blame
See line-by-line history of a specific file:
git blame src/path/to/file.jsx
git log for specific file
Track all changes to a file:
git log --oneline -p -- src/path/to/file.jsx
git status --porcelain
This command offers a concise, machine-readable representation of the Git repository’s status, which is suitable for scripting. I had to learn this because I needed to develop logic that required me to know the number of files currently being edited. If the output is empty, it indicated that no files had been edited.
git rev-parse name-of-branch
This is as I understand is a basic command that is used for script manipulation. Some tools are created based on this. Basically it gives SHA1 of the revision. Revision is name of the branch.
We can pass different options to get different results. More on this in docs post
git checkout stash@{0} -- path/to/your/file
This command get one file from the stash instead all what's there.
git show branch:file > file
# example
git show master:src/components/layouts/AppBar.jsx > src/components/layouts/AppBar.jsx
This will override current AppBar.jsx file with the one from master. git show gives you the body of a file and > will pass it and override file you give.