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

# ----- 片段 1 (bash) -----
git checkout -b feature/login
# ……开发、提交……
git push -u origin feature/login

# ----- 片段 2 (bash) -----
git push
# ! [rejected] main -> main (fetch first)
# 别慌,这是 Git 在保护你
git pull --rebase
git push

# ----- 片段 3 (bash) -----
echo "print('你好')" > hello.py
git add hello.py && git commit -m "add hello"
git push

# —— 终端 A:改了问候语并推送 ——
echo "print('早上好')" > hello.py
git commit -am "A 改的问候语"
git push

# —— 终端 B:晚一步,也改了同一行 ——
echo "print('晚上好')" > hello.py
git commit -am "B 改的问候语"
git pull --rebase

# ----- 片段 4 (text) -----
<<<<<<< HEAD
print('早上好')
=======
print('晚上好')
>>>>>>> B 改的问候语

# ----- 片段 5 (text) -----
print('早上好')
print('晚上好')

# ----- 片段 6 (bash) -----
git add hello.py
git rebase --continue

# ----- 片段 7 (bash) -----
git checkout main
git pull
git merge feature/login

# ----- 片段 8 (bash) -----
git push -u origin feature/login
# 在 GitHub 上点击 Compare & pull request
# 填写描述,指派 reviewer,等待审查
