man Git
Table of contents:
clear local cache
Sometimes we need to clear local cache to activate .gitignore or .gitmodules rules.
git rm -r --cached .
clone with submodules
Use --recurse-submodules to clone submodules and -j4 to clone then while cloning the main repo.
git clone --recurse-submodules -j4 git@github.com:<repo-name>.git
set user info
Need to be set before commit.
git config --global user.name "Your Nickname"
git config --global user.email your_email@example.com
gen new ssh-key and add to github
Use ssh-keygen to generate a new ssh-key. The ALGORITHM could be ed25519 or rsa. (ed25519 is better)
ssh-keygen -t ALGORITHM -C "your_email@example.com"
# ssh-keygen -t ed25519 -C "your_email@example.com"
# > Enter file in which to save the key (~/.ssh/id_ALGORITHM):[Press enter]
# > Enter passphrase (empty for no passphrase): [Type a passphrase]
# > Enter same passphrase again: [Type passphrase again]
Then copy the ssh pub key to your clipboard.
cat ~/.ssh/id_ALGORITHM.pub
# cat ~/.ssh/id_ed25519.pub
# Then select and copy the contents of the id_ALGORITHM.pub file
# displayed in the terminal to your clipboard
- After that, click
Settingsof your github page. - Find
SSH and GPG keys. - Click
New SSH keyorAdd SSH key. - In the “Title” field, add a descriptive label for the new key.
- For example, if you’re using a personal laptop, you might call this key “Personal laptop”.
- Select the type of key, either authentication or signing.
- In the “Key” field, paste your public key.
- Click
Add SSH key.