Github IO

Git入门

Git Concept: Version Control System

Components

Local

  • version repository: contains commits named by their SHA-1 hash
  • working copy: what you can see in the working director tracking by git.
  • stage area: for partial
  • shadow copy for remote: store the copy of remote

Remote

Remote repository, fast-forwarding only.

Local Work Flow

Local

1. Edit in Working Copy

  • tracking file: git add, git mv, git rm

2. Commit

Partial
  1. stage what you want to commit: git add <file>
  2. git restore --staged <file> untrack from stage.
  3. Checkout will be commit: git status
  4. commit the change file in the stage: git commit -m <message>
  5. git checkout: recover from commit.
All
  1. commit all the file: git commit -a -m <message>

Remote

Remote --> Shadow: git fetch

  • git pull = git fetch + git merge

Version Repository --> Remote: git push

  • if Remote is not a subset of Version Repository, you have to git fetch and git merge them first.

Status

git status: what will be commit

git log file/remote: commit history

git log -p: commit history and patches

Git Everyday

Single Person

  • git init
  • git add
  • git commit [--amend [--no-edit] ]
  • git restore
  • git diff HEAD
  • git merge
  • git switch [-c or --create]
  • git log
  • git tag

Participants

(待更新)

posted @ 2021-02-28 15:41  laiyk  阅读(64)  评论(0)    收藏  举报