Search in git
git rev-list --all | xargs git grep -F ''
Count commits
git rev-list --count main
View a file of another branch
git show dev:main.go
Take a backup of untracked files
git ls-files --others --exclude-standard -z | xargs -0 tar rvf backup-untracked.zip
Submodule
# Add submodule
git submodule add -b main git@github.com:linzeyan/toha.git themes/toha

# Update submodule
git submodule update --init --remote

# Remove submodule
modulePath="themes/toha"
git submodule deinit -f ${modulePath}
git rm ${modulePath}
rm -rf .git/modules/${modulePath}
git config --remove-section submodule.${modulePath}.
rm -f .gitmodules
commit hash
git rev-parse HEAD
commit tag
git describe --tags
worktree
# list
git worktree list

# add
git worktree add ../dirname branch-name
git config
[user]
  email = zeyanlin@outlook.com
  name = Ricky
  signingkey = 2A4313489FDCA802ED6FCC214B03D879EA73DF37
[commit]
  gpgsign = true
git config1

For golang import package

[url "git@gitlab.example.com:"]
    insteadOf = https://gitlab.example.com/
git config2
[includeIf "gitdir:~/work/"]
    path = ~/.gitconfig-work