Git useful commands

Published: Fri 28 April 2023
Updated: Fri 03 May 2024

Delete submodule


# Remove the submodule entry from .git/config
git submodule deinit -f path/to/submodule

# Remove the submodule directory from the superproject's .git/modules directory
rm -rf .git/modules/path/to/submodule

# Remove the entry in .gitmodules and remove the submodule directory located at path/to/submodule
git rm -f path/to/submodule

Modify a commit (not last one)


git rebase --interactive bbc643cd~
# in vim, modify this commit to edit
git commit --all --amend --no-edit
git rebase --continue


Git LFS enables clone to fetch large files associated with a specific commit, rather than it's full history. One needs to install git-lfs first:

apt-get install git-lfs

ref: (Chinese)