Created
December 22, 2019 03:13
-
-
Save Fireforge/c363895679b4606666de16e90bb3e593 to your computer and use it in GitHub Desktop.
Git Cheatsheet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Update all the submodules to the latest version: | |
git submodule foreach git pull origin master | |
# Prune a git repo of all folders EXCEPT the listed ones | |
git filter-branch --index-filter 'git rm --cached -qr --ignore-unmatch -- . && git reset -q $GIT_COMMIT -- apps/AAA libs/XXX' --prune-empty -- --all | |
# Remove all empty commits, but keep the commit info (author, date, etc.) | |
git filter-branch --prune-empty --parent-filter \ | |
'sed "s/-p //g" | xargs -r git show-branch --independent | sed "s/\</-p /g"' | |
#Git command to multiple dirs: | |
git add .; git commit -m "Removed unecessary dependencies and moved to snapshots"; git push origin master | |
ls -Directory -Exclude *-build,.* | ForEach-Object {Push-Location $_; "### $($_.Name) ###"; git --no-pager diff; Pop-Location } | |
# Get hash of current commit | |
git rev-parse --short HEAD | |
# Set up global gitignore | |
touch ~/.gitignore_global | |
git config --global core.excludesfile ~/.gitignore_global | |
# Enable credential cache, helps repeat user/pass prompts, esp. from git-lfs | |
git config --global credential.helper cache |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment