Contents

Git

git cli

git branch

  • git rev-parse --abbrev-ref HEAD

git tags

  • git describe --abbrev=0 --tags HEAD

git hash

  • git rev-parse HEAD

recover

corrupted Git repository

1
2
3
4
5
6
mv -v .git .git_old &&            # Remove old Git files
git init &&                       # Initialise new repository
git remote add origin "${url}" && # Link to old repository
git fetch &&                      # Get old history
# Note that some repositories use 'master' in place of 'main'. Change the following line if your remote uses 'master'.
git reset origin/main --mixed     # Force update to old history.

ssh key

key gen

1
ssh-keygen -t id_ed25519 -f ~/.ssh/github -C "email@example.com"

zsh git

oh-my-zsh.hide-status

1
2
git config --add oh-my-zsh.hide-status 1
git config --add oh-my-zsh.hide-dirty 1

clone

single branch

1
git clone <url> --branch <branch/tag> --single-branch [<folder>]

submodule