Revert local changes (uncommited):
git checkout <pathspec>
Rewrite remote with local changes without merging
git push -f
Go back to branch:
git revert --no-commit 0766c053..HEAD
git rm --cached <FILEPATH>
usefull params:
-r
: recursive - deletes content of directories-n
dry runTo reset an individual file, call: git checkout <filepath>
Can be used in gitignore and also in some git commands. All described in the Manual. Usefull wildcards:
**/
in any directory/**
everything in a directoryRemoving files from history can be done using multiple tools:
filter-branch
command is the original tool for filtering git history. It is slow and problematic, so it should be used only if the above two tools are not available. No matter of the used tool, before you begin:
Similarly, at the end:
With BFG, only a file with specific filename can be deleted. It is not possible to use exact file path. To remove file by its name:
--mirror
optionbfg --delete-files <FILENAME>
The git filter-repo can be installed using pip: pip install git-filter-repo
.
To remove file by its path:
git filter-repo --invert-paths --force --dry-run --path <PATH TO THE FILE TO BE REMOVED>
.git/filter-repo
directory:
original-oid
,
sed 's/original-oid .*//'
git remote add origin <REPO SSH ADDRESS>
git push origin --force --all
git filter-branch --force --index-filter 'git rm --cached --ignore-unmatch <FILE>' --prune-empty --tag-name-filter cat -- --all
Syntax:
git merge <params> <commit>
Merge can be aborted at any time by calling git merge --abort
. This resets the state of the repository.
Sometimes, it's necessary to tweak the command to help it locate the moved files. What can help:
-X rename-threshold=25
: Changing the threshold is important for languages that changes the file content when moving it with automatic refactoring (especially important for Java files, which usually have tons of imports)-X ignore-space-change
git revert -m 1
Note that when the merge is reverted, the changes cannot be merged again, because they predates the revert!
On windows, run: git update-git-for-windows
https://github.com/piceaTech/node-gitlab-2-github