My own git cheatsheet


June 1, 2020

I noticed I always google the same procedures…

Remove a file from a commit

Direct remove without editing anything:

git reset HEAD^ -- path/to/file
git commit --amend --no-edit


git reset --soft HEAD~1
git reset HEAD path/to/unwanted_file
git commit -c ORIG_HEAD


Only checkout a subset of files stored in git LFS

GIT_LFS_SKIP_SMUDGE=1 gh repo clone orgname/reponame

Then checkout only specific files:

git lfs fetch --include="pattern*" --exclude=""
git lfs checkout

Configure git to automatically run git submodule update

This works when switching branches:

git config --global submodule.recurse true