git rm {file_name} --cached
git commit --amend --no-edit
git checkout -- {filename}
git diff 8b33892 c5ecc5c
git checkout {--patch} {branch} {filepath}
- Find log
git log --oneline --graph
- Cherry pick a range —
git cherry-pick ebe6942..905e279
git checkout --patch branch-from path/to/file.js
git mv [old_name_with_path] [new_name_with_path]
git push -d <remote_name> <branch_name>
git branch -d <branch_name>
git merge branch --strategy-option theirs
git branch -a --contains <commit>
git add {filename} --patch
>
* y stage this hunk for the next commit
* n do not stage this hunk for the next commit
* q quit; do not stage this hunk or any of the remaining hunks
* a stage this hunk and all later hunks in the file
* d do not stage this hunk or any of the later hunks in the file
* g select a hunk to go to
* / search for a hunk matching the given regex
* j leave this hunk undecided, see next undecided hunk
* J leave this hunk undecided, see next hunk
* k leave this hunk undecided, see previous undecided hunk
* K leave this hunk undecided, see previous hunk
* s split the current hunk into smaller hunks
* e manually edit the current hunk
* You can then edit the hunk manually by replacing +/- by #
* ? print hunk help
<
How to remove all occurances of a file or a directory from git history (this creates new history and removes remote origin)
git filter-branch --tree-filter 'rm -rf node_modules' --prune-empty HEAD --force
git clean --force
git fetch --prune
git pull --prune
git branch -m {oldName} {newName}
Or when on the same branch git branch -m {newName}