git 學習

git help 查看全部命令

$ git help
usage: git [--version] [--help] [-C <path>] [-c <name>=<value>]
           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
           [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
           <command> [<args>]

These are common Git commands used in various situations:

start a working area (see also: git help tutorial)
   clone             Clone a repository into a new directory
   init              Create an empty Git repository or reinitialize an existing one

work on the current change (see also: git help everyday)
   add               Add file contents to the index
   mv                Move or rename a file, a directory, or a symlink
   restore           Restore working tree files
   rm                Remove files from the working tree and from the index
   sparse-checkout   Initialize and modify the sparse-checkout

examine the history and state (see also: git help revisions)
   bisect            Use binary search to find the commit that introduced a bug
   diff              Show changes between commits, commit and working tree, etc
   grep              Print lines matching a pattern
   log               Show commit logs
   show              Show various types of objects
   status            Show the working tree status

grow, mark and tweak your common history
   branch            List, create, or delete branches
   commit            Record changes to the repository
   merge             Join two or more development histories together
   rebase            Reapply commits on top of another base tip
   reset             Reset current HEAD to the specified state
   switch            Switch branches
   tag               Create, list, delete or verify a tag object signed with GPG

collaborate (see also: git help workflows)
   fetch             Download objects and refs from another repository
   pull              Fetch from and integrate with another repository or a local branch
   push              Update remote refs along with associated objects

'git help -a' and 'git help -g' list available subcommands and some
concept guides. See 'git help <command>' or 'git help <concept>'
to read about a specific subcommand or concept.
See 'git help git' for an overview of the system.

git help xxx

例如:git help log 會在默認瀏覽器中打開一個頁面,顯示命令詳情html

git log

git log --oneline // 日誌顯示的格式 one line

git log -n number // 顯示指定 number 數量的日誌

git log --graph --oneline // 能夠查詢 提交記錄的圖

git status

提交的產生一般被分爲兩個步驟。首先咱們用add命令將全部相關的修改歸入到暫存區(staging area),接着才能用commit命令將暫存區中的修改傳送到版本庫中。 經過status命令,能夠查看當前工做區中所發生的修改,以及其中的哪些修改已經被註冊到了暫存區中。git

上圖可按照如下幾個小標題瀏覽器

  • Changes to be committed:這部分修改已經在暫存區中,將在下次commit中被歸入版本庫中
  • Changes not staged for commit:這部分修改尚未添加到暫存區,下次commit時不會被提交到版本庫中
  • Untracked files:偉被追蹤的文件

在每一個標題下面,git都有相關的幫助提高,告訴咱們應該用什麼命令來從新改變這些狀態。app

例如:咱們能夠用如下命令將 foot.txt移出暫存區。ide

git restore --staged foo.txt
相關文章
相關標籤/搜索