# ===== CodeLab: git-remote =====
# 以下代码片段按文章出现顺序拼接, 共 8 段

# ----- 片段 1 (bash) -----
git config --global user.name "你的名字"
git config --global user.email "你的邮箱"

# ----- 片段 2 (bash) -----
ssh-keygen -t ed25519 -C "你的邮箱"
# 一路回车即可,默认保存到 ~/.ssh/id_ed25519
cat ~/.ssh/id_ed25519.pub

# ----- 片段 3 (bash) -----
ssh -T git@github.com
# 看到 Hi 用户名! 就说明通了

# ----- 片段 4 (bash) -----
git remote add origin git@github.com:你的用户名/仓库名.git
git push -u origin main

# ----- 片段 5 (bash) -----
git remote -v
# origin  git@github.com:用户名/仓库名.git (fetch)
# origin  git@github.com:用户名/仓库名.git (push)

# ----- 片段 6 (bash) -----
git clone git@github.com:用户名/仓库名.git
cd 仓库名

# ----- 片段 7 (bash) -----
git pull

# ----- 片段 8 (bash) -----
git remote add upstream git@github.com:原作者/仓库名.git
git fetch upstream
git merge upstream/main
