Skip to content

Instantly share code, notes, and snippets.

@blackpioter
Last active May 1, 2025 10:34
Show Gist options
  • Select an option

  • Save blackpioter/bbc548aa1a9721dbccd3ec9c90800bd3 to your computer and use it in GitHub Desktop.

Select an option

Save blackpioter/bbc548aa1a9721dbccd3ec9c90800bd3 to your computer and use it in GitHub Desktop.
git cheatsheet
## git reset hard to upstream
git reset --hard @{u}
## git remove directory from history
for branch in `git branch -a | grep remotes | grep -v HEAD | grep -v master`; do\n git branch --track ${branch##*/} $branch\ndone
git filter-branch -f --index-filter 'git rm --cached -r --ignore-unmatch DIRECTORY' \
--prune-empty --tag-name-filter cat -- --all
git filter-branch --index-filter \
'git rm -r --cached --ignore-unmatch DIRECTORY' HEAD
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment