- Windows Git client sets core.ignorecase to true by default, you may need to disable it to detect server changes on file names.
Check it by
git config --get core.ignorecase
, and set it bygit config core.ignorecase false
. - Detect file EOL by
git grep -I '^M'
. It searches for a literal CR character in files.
- To
git show
more lines before and after the changed lines, usegit show -U <NUM>
. - To
git diff
a file/dir between two commits, usegit diff <first-commit> <second-commit> [--] <filepath>
. Eithercommit
can be omitted, in which case it's as ifHEAD
is used for that omitted commit.
- Push all branches:
git push --all origin
- Push all tags:
git push --tags
Reset/force update the local branch you're currently on(dropping any local changes including untracked files): git reset --hard <commit>
. The commit
can be either a history commit on the branch, or not.
- Reset all files and directories to HEAD and remove all untracked ones:
git clean -xdf
- Reset all files and directories to HEAD but do not remove any untracked one:
git clean -Xdf
-
Patch commits since a commit(exclued) to the
HEAD
into one file:git format-patch <commit> --stdout > <patch-file>
-
Apply a patch file:
git am <patch-file>
When there's a conflict in applying patch, do it like
git am -3 <patch-file>
to enable 3-way merge, much like resolving a merge conflict.