Git Cheatsheet
Dec 4, 2018
My git cheatsheet
Remove Already Ignored Files
1 | git rm -r --cached . # Remove already ignored files. |
Check Who Modified This Line
To see commits affecting line 40 of file foo:git blame -L 40,+1 foo
The +1 means exactly one line. To see changes for lines 40-60, it’s:git blame -L 40,+21 foo
From line to line. The second number can be an offset designated with a ‘+’, or a line number. git blame docsgit blame -L 40,60 foo
Submodules
If you clone the repository, the submodule will not be cloned by default. If you want to clone all submodules while clone the repository, this is the command:
1 | git clone —-recurse-submodules URL |
If you have already cloned your repository, you can run this command. Omit
1 | git submodule update --init --recursive <pathspec> |
