Delete tracked files in directory:
git ls-files -z | xargs -0 rm -rf
Delete a file from history of a branch:
git filter-branch --index-filter "git rm --cached -f --ignore-unmatch <path/filename>"
See log with files changed:
git log --name-status
Delete remote branch:
git push origin :<remote-branch-name>
Split repository (make a subfolder a new repository):
- clone the branch with
git checkout -b <new-branch-name>
- turn the newly cloned branch to be its own repository:
git filter-branch --prune-empty --subdirectory-filter <subdir>
- the cloned branch will now have only commits related to the files under and we can push it to a new repository
git push <remote> <branch>' (before that we need to have the
remotedefined with
git remote ...`
See the git commands done so far:
git reflog
Undo any git filter-branch
command:
- get the ref ID from
git reflog
git reset --hard HEAD@{ID}
Search for commit hash by message:
git log --all --grep='message'
Get closest tag that contains commit hash
git describe --abbrev=0 --tags
Delete obsolete remote branches:
git remote prune origin
Show all tags that contain specific commit hash:
git tag --contains <commit hash>