极简 git 步骤

Revision as of 19:34, 22 July 2026 by Mwroot (talk | contribs) (Created page with "== 本地 == # cd sth # git init # git status # 写 .gitignore # git add . # git status # git diff --staged ;; commit 前先检查一下 # git commit -m "本次干了什么,下一步干什么" == 远程 == # git config --global user.name "你的名字" # git config --global user.email "你的邮箱" # git config --global --list # git remote add origin somewhere.git ;; origin 只是个昵称 # git remote -v # git branch -M main # git push -u origin main ;; u 表示 mai...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

本地

  1. cd sth
  2. git init
  3. git status
  4. 写 .gitignore
  5. git add .
  6. git status
  7. git diff --staged ;; commit 前先检查一下
  8. git commit -m "本次干了什么,下一步干什么"

远程

  1. git config --global user.name "你的名字"
  2. git config --global user.email "你的邮箱"
  3. git config --global --list
  4. git remote add origin somewhere.git ;; origin 只是个昵称
  5. git remote -v
  6. git branch -M main
  7. git push -u origin main ;; u 表示 main = origin/main
  8. git push
  9. git pull

项目要么生在本地,要么生在远程。本地已有,则远程建空仓,不要选创建 README.md License。远程已有,则本地直接 git clone。