Git學(xué)習(xí)筆記

初識(shí)git

git官網(wǎng)

作者簡(jiǎn)介

作者:林納斯·托瓦茲(Linus Benedict Torvalds, 1969年~ ),著名的電腦程序員隧魄、黑客。Linux內(nèi)核的發(fā)明人及該計(jì)劃的合作者隘蝎。托瓦茲利用個(gè)人時(shí)間及器材創(chuàng)造出了這套當(dāng)今全球最流行的操作系統(tǒng)(作業(yè)系統(tǒng))內(nèi)核之一购啄。(大學(xué)期間寫出了Linux的內(nèi)核)。

托瓦茲照片

版本管理的三個(gè)發(fā)展階段

本地式

最早的版本管理模式嘱么,在一臺(tái)電腦上作業(yè)狮含,在本地有一個(gè)版本庫(kù),用來(lái)存放文件。

本地式版本管理
  • 優(yōu)點(diǎn):安全
  • 缺點(diǎn):
    • 只能在單臺(tái)電腦進(jìn)行版本管理
    • 無(wú)法與多人協(xié)作

集中式

有一臺(tái)服務(wù)器專門當(dāng)作版本倉(cāng)庫(kù)几迄,用于存放文件蔚龙,

集中式
  • 優(yōu)點(diǎn):可以多人協(xié)作了
  • 缺點(diǎn):
    • 如果網(wǎng)絡(luò)不好,則無(wú)法進(jìn)行版本管理
    • 如果本人不在局域網(wǎng)中也無(wú)法進(jìn)行版本管理
    • 需要定期備份
    • 如果服務(wù)器掛掉映胁,需要數(shù)據(jù)恢復(fù)才可以版本管理木羹,當(dāng)然如果沒(méi)有定期備份,只能~~呵呵了

分布式

分布式

每個(gè)參與項(xiàng)目的人都會(huì)有一個(gè)完整的倉(cāng)庫(kù)信息屿愚,即使服務(wù)器掛掉汇跨,可以新起項(xiàng)目务荆,上傳文件妆距,這個(gè)新項(xiàng)目有以前所有的版本信息,不影響大家作業(yè)函匕,甚至可以在家作業(yè)娱据,然后第二天將正確的版本跟新上傳到的服務(wù)器。

補(bǔ)充:git和svn等存儲(chǔ)方式的區(qū)別

區(qū)別

  • svn存儲(chǔ)方式

  • git存儲(chǔ)方式

因此盅惜,在使用svn的時(shí)候是在需要提交文件的上級(jí)目錄管理此目錄全部的文件中剩。
但是,git是只要在此工程下抒寂,管理的都是該工程的文件结啼,因此如果使用git在分支合并,git pull的時(shí)候一定要將本項(xiàng)目的文件commit才可以屈芜,要不然很容易會(huì)合并失敗郊愧,甚至是沖突很多文件

git的誕生

有興趣的可以自己查一下

使用git

初次運(yùn)行g(shù)it前的配置

  1. 查看git的幫助,提示git后面可選的操作

    git --help
    
  2. 查看git某種操作的幫助

    git clone -h
    git clone --help
    
  3. 初次運(yùn)行g(shù)it前的配置

    可以不用先不考慮,當(dāng)需要的時(shí)候再去根據(jù)提示進(jìn)行配置

    • /etc/gitconfig 文件:系統(tǒng)中對(duì)所有用戶都普遍適用的配置井佑。若使用 git config 時(shí)用 --system 選項(xiàng)属铁,讀寫的就是這個(gè)文件。
    • ~/.gitconfig 文件:用戶目錄下的配置文件只適用于該用戶躬翁。若使用 git config 時(shí)用 --global 選項(xiàng)焦蘑,讀寫的就是這個(gè)文件。
    • 當(dāng)前項(xiàng)目的 Git 目錄中的配置文件(也就是工作目錄中的 .git/config 文件):這里的配置僅僅針對(duì)當(dāng)前項(xiàng)目有效盒发。每一個(gè)級(jí)別的配置都會(huì)覆蓋上層的相同配置例嘱,所以 .git/config 里的配置會(huì)覆蓋 /etc/gitconfig中的同名變量。

    在 Windows 系統(tǒng)上宁舰,Git 會(huì)找尋用戶主目錄下的 .gitconfig 文件拼卵。主目錄即 HOME 變量指定的目錄,一般都是 C:\Documents and Settings\USER明吩。此外间学,Git 還會(huì)嘗試找尋 /etc/gitconfig 文件,只不過(guò)看當(dāng)初 Git 裝在什么目錄,就以此作為根目錄來(lái)定位低葫。

  4. 用戶信息

    • 查看幫助

      git config  -h
      
    • 設(shè)置

      git config --global user.name "xxx"
      git config --global user.email "xxx@xxx.com"
      
  5. 文本編輯器

    可以考慮不設(shè)置

    git config --global core.editor emacs
    
  6. 差異分析工具

    git config --global merge.tool vimdiff
    
  7. 查看配置信息

    git config --list

    user.name=xxx
    user.email=xxx@xxx.com
    merge.tool=vimdiff
    
    color.status=auto
    color.branch=auto
    color.interactive=auto
    color.diff=auto
    ...
    
  8. 直接閱讀變量

    git config user.name
    
  9. 獲取幫助

    git help <verb>
    git <verb> --help
    man git-<verb>
    

創(chuàng)建第一個(gè)版本庫(kù)和第一次提交

  1. 創(chuàng)建一個(gè)版本庫(kù)

    [root@Jolay data]# git init demo
    Initialized empty Git repository in /data/demo/.git/
    [root@Jolay data]# ls
    demo
    [root@Jolay data]# ll -a demo/
    total 0
    drwxr-xr-x 3 root root  17 Nov  8 23:17 .
    drwxr-xr-x 3 root root  17 Nov  8 23:17 ..
    drwxr-xr-x 7 root root 111 Nov  8 23:17 .git
    

    此時(shí):創(chuàng)建庫(kù)成功

  2. 第一次提交

    git 幾個(gè)區(qū)域的概念

    文件的變化狀態(tài)

    先透露一個(gè)命令 git status:查看本地git倉(cāng)庫(kù)的狀態(tài)

    追蹤一個(gè)文件前详羡,查看本地倉(cāng)庫(kù)的狀態(tài)

    [root@Jolay data]# cd demo/
    [root@Jolay demo]# ls
    [root@Jolay demo]# touch a.txt
    [root@Jolay demo]# ls
    a.txt
    [root@Jolay demo]# git status
    # On branch master
    #
    # Initial commit
    #
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       a.txt
    nothing added to commit but untracked files present (use "git add" to track)
    

    追蹤文件后,查看本地倉(cāng)庫(kù)的狀態(tài)

    [root@Jolay demo]# ls
    a.txt
    [root@Jolay demo]# git add a.txt
    [root@Jolay demo]# git status
    # On branch master
    #
    # Initial commit
    #
    # Changes to be committed:
    #   (use "git rm --cached <file>..." to unstage)
    #
    #       new file:   a.txt
    #
    [root@Jolay demo]#
    

    提交一個(gè)文件后嘿悬,查看本地倉(cāng)庫(kù)的狀態(tài)

    [root@Jolay demo]# git commit -m "first commit"
    [master (root-commit) b7172f0] first commit
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 a.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]#  
    
  1. 第二次提交

    [root@Jolay demo]# ls
    a.txt
    [root@Jolay demo]# echo hello > a.txt 
    [root@Jolay demo]# git status
    # On branch master
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   a.txt
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    [root@Jolay demo]# 
    [root@Jolay demo]# git add a.txt 
    [root@Jolay demo]# git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       modified:   a.txt
    #
    [root@Jolay demo]# git commit -m "second commit"
    [master 02ddd86] second commit
     1 file changed, 1 insertion(+)
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]# 
    
  2. 第三次提交

    [root@Jolay demo]# ls
    a.txt
    [root@Jolay demo]# touch b.txt c.txt
    [root@Jolay demo]# 
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       b.txt
    #       c.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# git add b.txt
    [root@Jolay demo]# git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   b.txt
    #
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       c.txt
    [root@Jolay demo]# git commit -m "third commit"
    [master ab73ce8] third commit
     1 file changed, 0 insertions(+), 0 deletions(-)
     create mode 100644 b.txt
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       c.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# 
    
    文件的變化狀態(tài)

git的提交信息git commit

  1. 查看git的commit信息

    方式一:

    [root@Jolay demo]# git log
    commit 02ddd86425e4333ab72afe5b59b593d5a3eea9a4
    Author: xxx <xxx@xxx.com>
    Date:   Tue Nov 8 23:42:21 2016 +0800
    
        second commit
    
    commit b7172f012572a064fd057577250020528209e902
    Author: xxx <xxx@xxx.com>
    Date:   Tue Nov 8 23:27:31 2016 +0800
    
        first commit
    [root@Jolay demo]# 
    

    方式二:

    只有在初始化倉(cāng)庫(kù)实柠,提交過(guò)一次過(guò)后才能使用(查看上一次提交信息)

    [root@Jolay demo]# git show
    commit 02ddd86425e4333ab72afe5b59b593d5a3eea9a4
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:42:21 2016 +0800
    
        second commit
    
    diff --git a/a.txt b/a.txt
    index e69de29..ce01362 100644
    --- a/a.txt
    +++ b/a.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]#
    

git暫存區(qū)(追蹤)git add

  1. 添加一個(gè)文件

    添加一個(gè)文件,并查看添加文件(追蹤文件)后的狀態(tài)善涨,

    [root@Jolay demo]# ls
     a.txt  b.txt  c.txt
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       c.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# git add c.txt 
    [root@Jolay demo]# git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   c.txt
    #
    [root@Jolay demo]# 
    
  2. 修改一個(gè)文件

    [root@Jolay demo]# echo "hello world" > c.txt
    [root@Jolay demo]# git status
    # On branch master
    # Changes to be committed:
    #   (use "git reset HEAD <file>..." to unstage)
    #
    #       new file:   c.txt
    #
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   c.txt
    #
    [root@Jolay demo]# 
    [root@Jolay demo]# git commit -m "test"
    [root@Jolay demo]# git status
    

文件的回滾

  1. 環(huán)境準(zhǔn)備

    將所有的數(shù)據(jù)都提交

    [root@Jolay demo]# git add .
    [root@Jolay demo]# git commit -m "forth commit"
    [master d46cff7] forth commit
     1 file changed, 1 insertion(+)
     create mode 100644 c.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]# 
    
  2. 回滾未追蹤的文件窒盐,比如新增文件

    此類文件,直接刪除就好

    [root@Jolay demo]# touch d.txt
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       d.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# 
    
  3. 回滾新git add的文件

    方式一:如果是新加的文件钢拧,此方式回滾

    此處親自操組一下,看提示
    1. 新加文件
    2. git status
    3. git add
    4. git status
    5. 回滾
    6. git status
    7. git add
    8. git status
    9. 修改文件
    10. git status
    11. 回滾文件
    
  4. 回滾git commit的文件
    實(shí)驗(yàn)環(huán)境

    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       d.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# git add .
    [root@Jolay demo]# git commit -m 'fifth commit'
    [master 2665767] fifth commit
     1 file changed, 1 insertion(+)
     create mode 100644 d.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    
    [root@Jolay demo]# git show
    commit 2665767519ab995e56ca7a5758c3a799d14bdad8
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:39:01 2016 +0800
    
        fifth commit
    
    diff --git a/d.txt b/d.txt
    new file mode 100644
    index 0000000..ce01362
    --- /dev/null
    +++ b/d.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]# 
    

    回滾操作

    [root@Jolay demo]# git add .
    [root@Jolay demo]# git commit -m 'fifth commit'
    [master 2665767] fifth commit
     1 file changed, 1 insertion(+)
     create mode 100644 d.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    
    [root@Jolay demo]# git show
    commit 2665767519ab995e56ca7a5758c3a799d14bdad8
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:39:01 2016 +0800
    
        fifth commit
    
    diff --git a/d.txt b/d.txt
    new file mode 100644
    index 0000000..ce01362
    --- /dev/null
    +++ b/d.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git reset 2665767519ab995e56ca7a5758c3a799d14bdad8
    [root@Jolay demo]# git show 
    commit 2665767519ab995e56ca7a5758c3a799d14bdad8
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:39:01 2016 +0800
    
        fifth commit
    
    diff --git a/d.txt b/d.txt
    new file mode 100644
    index 0000000..ce01362
    --- /dev/null
    +++ b/d.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]# git log
    commit 2665767519ab995e56ca7a5758c3a799d14bdad8
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:39:01 2016 +0800
    
        fifth commit
    
    commit d46cff75ca3d775db42c31afdf1ebd4c1b04c2d2
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:14:13 2016 +0800
    
        forth commit
    
    commit ab73ce8273017bad67ccb575ab82755dbedf103e
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:51:49 2016 +0800
    
        third commit
    
    commit 02ddd86425e4333ab72afe5b59b593d5a3eea9a4
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:42:21 2016 +0800
    
        second commit
    
    commit b7172f012572a064fd057577250020528209e902
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:27:31 2016 +0800
    
        first commit
    [root@Jolay demo]# git reset d46cff75ca3d775db42c31afdf1ebd4c1b04c2d2
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       d.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# git show
    commit d46cff75ca3d775db42c31afdf1ebd4c1b04c2d2
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:14:13 2016 +0800
    
        forth commit
    
    diff --git a/c.txt b/c.txt
    new file mode 100644
    index 0000000..3b18e51
    --- /dev/null
    +++ b/c.txt
    @@ -0,0 +1 @@
    +hello world
    [root@Jolay demo]# git log
    commit d46cff75ca3d775db42c31afdf1ebd4c1b04c2d2
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:14:13 2016 +0800
    
        forth commit
    
    commit ab73ce8273017bad67ccb575ab82755dbedf103e
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:51:49 2016 +0800
    
        third commit
    
    commit 02ddd86425e4333ab72afe5b59b593d5a3eea9a4
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:42:21 2016 +0800
    
        second commit
    
    commit b7172f012572a064fd057577250020528209e902
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:27:31 2016 +0800
    
        first commit
    [root@Jolay demo]# 
    
  5. 多次git commit之后想回滾到某一版本蟹漓,同上

    回滾只是本地倉(cāng)庫(kù)的回滾,工作空間不會(huì)被修改源内,當(dāng)需要覆蓋時(shí)葡粒,使用git checkout 文件名

    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git status
    # On branch master
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #
    #       d.txt
    nothing added to commit but untracked files present (use "git add" to track)
    [root@Jolay demo]# git add .
    [root@Jolay demo]# git commit -m "fifth commit"
    [master 41aa3e1] fifth commit
     1 file changed, 1 insertion(+)
     create mode 100644 d.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]# echo world > d.txt 
    [root@Jolay demo]# git status
    # On branch master
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   d.txt
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    [root@Jolay demo]# git add d.txt 
    [root@Jolay demo]# git commit -m "sixth commit"
    [master 0cc2a7d] sixth commit
     1 file changed, 1 insertion(+), 1 deletion(-)
    [root@Jolay demo]# git log
    commit 0cc2a7d9e61b2226f1a10c52e02a0ab9c2fe5a53
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:47:30 2016 +0800
    
        sixth commit
    
    commit 41aa3e15902ea6fff8df3853ae98754ac050f65d
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:46:52 2016 +0800
    
        fifth commit
    
    commit d46cff75ca3d775db42c31afdf1ebd4c1b04c2d2
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:14:13 2016 +0800
    
        forth commit
    
    commit ab73ce8273017bad67ccb575ab82755dbedf103e
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:51:49 2016 +0800
    
        third commit
    
    commit 02ddd86425e4333ab72afe5b59b593d5a3eea9a4
    Author: xxx <xxx@foxmail.com>
    Date:   Tue Nov 8 23:42:21 2016 +0800
    
        second commit
    
    commit b7172f012572a064fd057577250020528209e902
    [root@Jolay demo]# git reset 41aa3e15902ea6fff8df3853ae98754ac050f65d
    Unstaged changes after reset:
    M       d.txt
    [root@Jolay demo]# git status
    # On branch master
    # Changes not staged for commit:
    #   (use "git add <file>..." to update what will be committed)
    #   (use "git checkout -- <file>..." to discard changes in working directory)
    #
    #       modified:   d.txt
    #
    no changes added to commit (use "git add" and/or "git commit -a")
    [root@Jolay demo]# cat d.txt 
    world
    [root@Jolay demo]# git checkout d.txt    
    [root@Jolay demo]# cat d.txt 
    hello
    [root@Jolay demo]# 
    

    此時(shí)我們其實(shí)已經(jīng)穿插了git commit,提交給了本地倉(cāng)庫(kù)

  6. 總結(jié)文件的狀態(tài)變化

    理解比較復(fù)雜膜钓,可以根據(jù)git status提示操作嗽交。

    文件狀態(tài)的變化

    文件的變化狀態(tài)
  7. 移除被追蹤的文件

    盡量不要用

    git rm 文件名

    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git status
    # On branch master
    nothing to commit, working directory clean
    [root@Jolay demo]# git show
    commit 41aa3e15902ea6fff8df3853ae98754ac050f65d
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:46:52 2016 +0800
    
        fifth commit
    
    diff --git a/d.txt b/d.txt
    new file mode 100644
    index 0000000..ce01362
    --- /dev/null
    +++ b/d.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git rm d.txt 
    rm 'd.txt'
    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt
    [root@Jolay demo]# git show
    commit 41aa3e15902ea6fff8df3853ae98754ac050f65d
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 00:46:52 2016 +0800
    
        fifth commit
    
    diff --git a/d.txt b/d.txt
    new file mode 100644
    index 0000000..ce01362
    --- /dev/null
    +++ b/d.txt
    @@ -0,0 +1 @@
    +hello
    [root@Jolay demo]# git commit -m "rm d.txt"
    [master a443dea] rm d.txt
     1 file changed, 1 deletion(-)
     delete mode 100644 d.txt
    [root@Jolay demo]# 
    
  8. 重命名文件名

    git mv a.txt e.txt
    
  9. 查看狀態(tài)的另一種格式-s (--short)

    git status -s
    

    當(dāng)修改文件。add之后颂斜,再次修改文件夫壁,就會(huì)出現(xiàn)連個(gè)M。表示提交到暫存區(qū)后沃疮,又進(jìn)行了修改盒让,直接commit提交,會(huì)提交暫存區(qū)的文件忿磅,后修改的不回提交糯彬。只有再次add的時(shí)候會(huì)將后修改的內(nèi)容,添加到暫存區(qū)葱她,然后在此提交撩扒,會(huì)完成提交 添加測(cè)試代碼,快速回滾

    [xxx@ops-monitor demo4]$ git status -s
    MM a.txt
    [xxx@ops-monitor demo4]$ 
    

git查看提交歷史git log

git reflog
  1. git log 有許多選項(xiàng)可以幫助你搜尋感興趣的提交吨些,接下來(lái)我們介紹些最常用的搓谆。
    我們常用 -p 選項(xiàng)展開(kāi)顯示每次提交的內(nèi)容差異,用 -2 則僅顯示最近的兩次更新

    git log -p -2
    
  1. git log 新版本的參數(shù)--word-diff豪墅,單詞的差分泉手,而非行級(jí)別的差分

    git log -U1 --word-diff
    
  2. 另外,git log 還提供了許多摘要選項(xiàng)可以用偶器,比如 --stat斩萌,僅顯示簡(jiǎn)要的增改行數(shù)統(tǒng)計(jì):

    git log --stat
    
  1. 每個(gè)提交都列出了修改過(guò)的文件缝裤,以及其中添加和移除的行數(shù),并在最后列出所有增減行數(shù)小計(jì)颊郎。 還有個(gè)常用的 --pretty 選項(xiàng)憋飞,可以指定使用完全不同于默認(rèn)格式的方式展示提交歷史。比如用 oneline 將每個(gè)提交放在一行顯示姆吭,這在提交數(shù)很大時(shí)非常有用榛做。另外還有 short,full 和 fuller 可以用内狸,展示的信息或多或少有些不同检眯,請(qǐng)自己動(dòng)手實(shí)踐一下看看效果如何。

    git log --pretty=oneline
    

    但最有意思的是 format昆淡,可以定制要顯示的記錄格式锰瘸,這樣的輸出便于后期編程提取分析,像這樣:

    git log --pretty=format:"%h - %an, %ar : %s"
    

    表 2-1 列出了常用的格式占位符寫法及其代表的意義瘪撇。

    選項(xiàng) 說(shuō)明
    %H 提交對(duì)象(commit)的完整哈希字串
    %h 提交對(duì)象的簡(jiǎn)短哈希字串
    %T 樹(shù)對(duì)象(tree)的完整哈希字串
    %t 樹(shù)對(duì)象的簡(jiǎn)短哈希字串
    %P 父對(duì)象(parent)的完整哈希字串
    %p 父對(duì)象的簡(jiǎn)短哈希字串
    %an 作者(author)的名字
    %ae 作者的電子郵件地址
    %ad 作者修訂日期(可以用 -date= 選項(xiàng)定制格式)
    %ar 作者修訂日期获茬,按多久以前的方式顯示
    %cn 提交者(committer)的名字
    %ce 提交者的電子郵件地址
    %cd 提交日期
    %cr 提交日期,按多久以前的方式顯示
    %s 提交說(shuō)明

你一定奇怪作者(author)和提交者(committer)之間究竟有何差別倔既,其實(shí)作者指的是實(shí)際作出修改的人,提交者指的是最后將此工作成果提交到倉(cāng)庫(kù)的人鹏氧。所以渤涌,當(dāng)你為某個(gè)項(xiàng)目發(fā)布補(bǔ)丁,然后某個(gè)核心成員將你的補(bǔ)丁并入項(xiàng)目時(shí)把还,你就是作者实蓬,而那個(gè)核心成員就是提交者。我們會(huì)在第五章再詳細(xì)介紹兩者之間的細(xì)微差別吊履。

用 oneline 或 format 時(shí)結(jié)合 --graph 選項(xiàng)安皱,可以看到開(kāi)頭多出一些 ASCII 字符串表示的簡(jiǎn)單圖形,形象地展示了每個(gè)提交所在的分支及其分化衍合情況艇炎。在我們之前提到的 Grit 項(xiàng)目倉(cāng)庫(kù)中可以看到:

git log --pretty=format:"%h %s" --graph
  1. 參數(shù)說(shuō)明

    選項(xiàng) 說(shuō)明
    -p 按補(bǔ)丁格式顯示每個(gè)更新之間的差異酌伊。
    --word-diff 按 word diff 格式顯示差異。
    --stat 顯示每次更新的文件修改統(tǒng)計(jì)信息缀踪。
    --shortstat 只顯示 --stat 中最后的行數(shù)修改添加移除統(tǒng)計(jì)居砖。
    --name-only 僅在提交信息后顯示已修改的文件清單。
    --name-status 顯示新增驴娃、修改奏候、刪除的文件清單。
    --abbrev-commit 僅顯示 SHA-1 的前幾個(gè)字符唇敞,而非所有的 40 個(gè)字符蔗草。
    --relative-date 使用較短的相對(duì)時(shí)間顯示(比如咒彤,“2 weeks ago”)。
    --graph 顯示 ASCII 圖形表示的分支合并歷史咒精。
    --pretty 使用其他格式顯示歷史提交信息蔼紧。可用的選項(xiàng)包括 oneline狠轻,short奸例,full,fuller 和 format(后跟指定格式)
    --oneline --pretty=oneline --abbrev-commit 的簡(jiǎn)化用法

    用 oneline 或 format 時(shí)結(jié)合 --graph 選項(xiàng)向楼,可以看到開(kāi)頭多出一些 ASCII 字符串表示的簡(jiǎn)單圖形查吊,形象地展示了每個(gè)提交所在的分支及其分化衍合情況。在我們之前提到的 Grit 項(xiàng)目倉(cāng)庫(kù)中可以看到:

  2. 另外還有按照時(shí)間作限制的選項(xiàng)湖蜕,比如 --since 和 --until逻卖。下面的命令列出所有最近兩周內(nèi)的提交:

    git log --since=2.weeks
    

    你可以給出各種時(shí)間格式,比如說(shuō)具體的某一天(“2008-01-15”)昭抒,或者是多久以前(“2 years 1 day 3 minutes ago”)

  3. 另一個(gè)真正實(shí)用的git log選項(xiàng)是路徑(path)评也,如果只關(guān)心某些文件或者目錄的歷史提交,可以在 git log 選項(xiàng)的最后指定它們的路徑灭返。因?yàn)槭欠旁谧詈笪恢蒙系倪x項(xiàng)盗迟,所以用兩個(gè)短劃線(--)隔開(kāi)之前的選項(xiàng)和后面限定的路徑名。

    選項(xiàng) 說(shuō)明
    -(n) 僅顯示最近的 n 條提交
    --since, --after 僅顯示指定時(shí)間之后的提交熙含。
    --until, --before 僅顯示指定時(shí)間之前的提交罚缕。
    --author 僅顯示指定作者相關(guān)的提交。
    --committer 僅顯示指定提交者相關(guān)的提交怎静。

    來(lái)看一個(gè)實(shí)際的例子邮弹,如果要查看 Git 倉(cāng)庫(kù)中,2008 年 10 月期間蚓聘,Junio Hamano 提交的但未合并的測(cè)試腳本(位于項(xiàng)目的 t/ 目錄下的文件)腌乡,可以用下面的查詢命令:

    $ git log --pretty="%h - %s" --author=gitster --since="2008-10-01" --before="2008-11-01" --no-merges -- t/
    

git分支的新建與合并

  1. 查看分支

    git branch
    

    顯示git 各個(gè)分支的版本

    [xxx@ops-monitor git]$ git branch -v
      dev    8b71aa6 24e24
    * master 8b71aa6 24e24
      test   6daa51f 12e1
    

    查看哪些分支合并進(jìn)當(dāng)前分支

    git branch --merged
    

    查看哪些分支未合并到當(dāng)前分支

    git branch --no-merged
    
  2. 同步遠(yuǎn)程數(shù)據(jù)到本地

    git fetch origin
    
    git merge master
    
  3. 推送本地分支到遠(yuǎn)端(此方法會(huì)推送整個(gè)分支)

    git push (遠(yuǎn)程倉(cāng)庫(kù)名) (分支名):
    
  4. 新建一個(gè)分支,但是這個(gè)分支直接拉取遠(yuǎn)端某分支的數(shù)據(jù)

    git checkout -b [分支名] [遠(yuǎn)程名]/[分支名]
    
  5. 刪除遠(yuǎn)端分支

    git push [遠(yuǎn)程名] :[分支名]
    

    遠(yuǎn)端

    git push origin --delete 分支名
    

    刪除本地分支

    git branch -d 分支名
    
  6. 分支合并

    git merge --no-ff dev
    

    推薦分支

    推薦分枝策略

    衍合

    git checkout dev
    git rebase master
    git checkout master
    git merge dev
    
    圖1

    圖2

    圖3

    圖4

    多分支的衍合

    圖1
    git rebase --onto master server client
    
    圖2
    git checkout master
    git merge client
    
    圖3
    git rebase master server
    
    圖4
    git checkout master
    git merge server
    
    git branch -d client
    git branch -d server
    
    圖5

    衍合的另一種解決

    圖2

git 差分文件

  1. 查看未暫存的文件進(jìn)行了哪些更新夜牡,比加參數(shù)直接git diff

    如果追蹤了文件与纽,可以用此命令差分(未追蹤的文件,由于未追蹤所以無(wú)法差分)

    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt
    [root@Jolay demo]# touch d.txt
    [root@Jolay demo]# echo hello > d.txt 
    [root@Jolay demo]# git diff
    [root@Jolay demo]# git add d.txt 
    [root@Jolay demo]# ls
    a.txt  b.txt  c.txt  d.txt
    [root@Jolay demo]# git diff
    [root@Jolay demo]# echo world > d.txt 
    [root@Jolay demo]# git diff
    diff --git a/d.txt b/d.txt
    index ce01362..cc628cc 100644
    --- a/d.txt
    +++ b/d.txt
    @@ -1 +1 @@
    -hello
    +world
    [root@Jolay demo]# 
    

    注意: 此條命令是比較工作目錄中打給你錢文件和暫存區(qū)域快照之間的差異氯材,也就是修改之后還沒(méi)有暫存起來(lái)的變化內(nèi)容

  2. 已經(jīng)暫存起來(lái)的文件渣锦,還沒(méi)有提交的內(nèi)容,可以用git diff --cached命令氢哮,或者是使用 git diff --staged

    [root@Jolay demo]# git show
    commit f82b272b2ce8b58a5278ab0997204e4f969617de
    Author: xxx <xxx@foxmail.com>
    Date:   Wed Nov 9 01:08:44 2016 +0800
    
        end
    
    diff --git a/d.txt b/d.txt
    index ce01362..cc628cc 100644
    --- a/d.txt
    +++ b/d.txt
    @@ -1 +1 @@
    -hello
    +world
    [root@Jolay demo]# echo cao > d.txt 
    [root@Jolay demo]# git add .
    [root@Jolay demo]# echo ya > d.txt 
    [root@Jolay demo]# git diff
    diff --git a/d.txt b/d.txt
    index d30c5c8..865493f 100644
    --- a/d.txt
    +++ b/d.txt
    @@ -1 +1 @@
    -cao
    +ya
    [root@Jolay demo]# git diff --cached
    diff --git a/d.txt b/d.txt
    index cc628cc..d30c5c8 100644
    --- a/d.txt
    +++ b/d.txt
    @@ -1 +1 @@
    -world
    +cao
    [root@Jolay demo]#
    
  1. git 差分分支

    git diff master
    
  2. 如果感覺(jué)使用暫存區(qū)很繁瑣袋毙,那么可以直接食用git commmit -a -m "" 參數(shù),但是這樣就無(wú)法使用暫存區(qū)的功能了冗尤,所以不推薦使用

    git commit -a -m " test -a var"
    
  3. git狀態(tài)的保存

    git stash
    git stash pop
    git stash apply
    git stash -q
    

git忽略不需要提交的文件

  1. 忽略文件

    cat .gitignore

    *.[oa]
    *.a
    

    忽略所有.0和.a的文件

    我們?cè)倏匆粋€(gè) .gitignore 文件的例子:

    # Untracked files:
    # no .a files
    *.a
    .project
    .classpath
    *.iml
    
     # only ignore the TODO file in the current directory, not subdir. /TODO
    /TODO
    
    # ignore all files in the build/ directory
    build/
    target/
    .setttings/
    .idea/
    
     # ignore doc/notes.txt, but not doc/server/arch.txt
    doc/*.txt
    
    # ignore all .pdf files in the doc/ directory
    doc/**/*.pdf
    
    # Tracked files:
    # but do track lib.a, even though you're ignoring .a files above
    !lib.a
    !target/ROOT.war
    !/.gitignore
    

git撤消操作

  1. 修改最后一次提交

    有時(shí)候我們提交完了才發(fā)現(xiàn)漏掉了幾個(gè)文件沒(méi)有加听盖,或者提交信息寫錯(cuò)了胀溺。想要撤消剛才的提交操作,可以使用 --amend 選項(xiàng)重新提交:
    如果剛才提交時(shí)忘了暫存某些修改皆看,可以先補(bǔ)上暫存操作仓坞,然后再運(yùn)行 --amend 提交:

    $ git commit -m 'initial commit'
    $ git add forgotten_file
    $ git commit --amend
    

    上面的三條命令最終只是產(chǎn)生一個(gè)提交,第二個(gè)提交命令修正了第一個(gè)的提交內(nèi)容腰吟。

  2. 對(duì)于已經(jīng)暫存的文件可以使用撤銷暫存的方式(注意是撤消暫存无埃,而不是回滾文件)

    其實(shí),git status 的命令輸出已經(jīng)告訴了我們?cè)撛趺醋觯壕驮?“Changes to be committed” 下面毛雇,括號(hào)中有提示嫉称,可以使用 git reset HEAD <file>... 的方式取消暫存。好吧灵疮,我們來(lái)試試取消暫存 benchmarks.rb 文件:

    $ git reset HEAD benchmarks.rb
    Unstaged changes after reset:
    M       benchmarks.rb
    $ git status
    On branch master
    Changes to be committed:
      (use "git reset HEAD <file>..." to unstage)
    
            modified:   README.txt
    
    Changes not staged for commit:
      (use "git add <file>..." to update what will be committed)
      (use "git checkout -- <file>..." to discard changes in working directory)
    
            modified:   benchmarks.rb
    
  3. 取消對(duì)文件的修改织阅,git checkout

    git checkout -- benchmarks.rb
    

git遠(yuǎn)程倉(cāng)庫(kù)的使用

  1. 顯示遠(yuǎn)端倉(cāng)庫(kù)(如果現(xiàn)實(shí)遠(yuǎn)端倉(cāng)庫(kù)的鏈接git remote -v

    git remote -v
    
  2. 要添加一個(gè)新的遠(yuǎn)程倉(cāng)庫(kù),可以指定一個(gè)簡(jiǎn)單的名字震捣,以便將來(lái)引用荔棉,運(yùn)行 git remote add [shortname] [url]

    $ git remote
    origin
    $ git remote add pb git://github.com/paulboone/ticgit.git
    $ git remote -v
    origin  git://github.com/schacon/ticgit.git
    pb  git://github.com/paulboone/ticgit.git
    
  3. 從遠(yuǎn)程倉(cāng)庫(kù)抓取數(shù)據(jù)

    git fetch [remote-name]
    

    例如:git fetch origin

    git pull
    

    推薦此種方法

  4. 推送數(shù)據(jù)到遠(yuǎn)程倉(cāng)庫(kù)

    git push [remote-name] [branch-name]
    
    git push origin master
    
  5. 查看遠(yuǎn)程倉(cāng)庫(kù)信息

    git remote show [remote-name] 
    
    git remote show origin
    

    它告訴我們,運(yùn)行 git push 時(shí)缺省推送的分支是什么(譯注:最后兩行)蒿赢。它還顯示了有哪些遠(yuǎn)端分支還沒(méi)有同步到本地(譯注:第六行的 caching 分支)润樱,哪些已同步到本地的遠(yuǎn)端分支在遠(yuǎn)端服務(wù)器上已被刪除(譯注:Stale tracking branches 下面的兩個(gè)分支),以及運(yùn)行 git pull 時(shí)將自動(dòng)合并哪些分支(譯注:前四行中列出的 issues 和 master 分支)

  6. 遠(yuǎn)程倉(cāng)庫(kù)的刪除和重命名

    重命名

    $ git remote rename pb paul
    $ git remote
    origin
    paul
    

    刪除

    $ git remote rm paul
    $ git remote
    origin
    

git 打標(biāo)簽

  1. 列顯已有的標(biāo)簽

    $ git tag
    v0.1
    v1.3
    

    顯示的標(biāo)簽按字母順序排列诉植,所以標(biāo)簽的先后并不表示重要程度的輕重祥国。

    我們可以用特定的搜索模式列出符合條件的標(biāo)簽。在 Git 自身項(xiàng)目倉(cāng)庫(kù)中晾腔,有著超過(guò) 240 個(gè)標(biāo)簽,如果你只對(duì) 1.4.2 系列的版本感興趣啊犬,可以運(yùn)行下面的命令:

    $ git tag -l 'v1.4.2.*'
    v1.4.2.1
    v1.4.2.2
    v1.4.2.3
    v1.4.2.4
    
  2. 含附注的標(biāo)簽

    Git 使用的標(biāo)簽有兩種類型:輕量級(jí)的(lightweight)和含附注的(annotated)灼擂。輕量級(jí)標(biāo)簽就像是個(gè)不會(huì)變化的分支,實(shí)際上它就是個(gè)指向特定提交對(duì)象的引用觉至。而含附注標(biāo)簽剔应,實(shí)際上是存儲(chǔ)在倉(cāng)庫(kù)中的一個(gè)獨(dú)立對(duì)象,它有自身的校驗(yàn)和信息语御,包含著標(biāo)簽的名字峻贮,電子郵件地址和日期,以及標(biāo)簽說(shuō)明应闯,標(biāo)簽本身也允許使用 GNU Privacy Guard (GPG) 來(lái)簽署或驗(yàn)證纤控。一般我們都建議使用含附注型的標(biāo)簽,以便保留相關(guān)信息碉纺;當(dāng)然船万,如果只是臨時(shí)性加注標(biāo)簽刻撒,或者不需要旁注額外信息,用輕量級(jí)標(biāo)簽也沒(méi)問(wèn)題耿导。

    創(chuàng)建一個(gè)含附注類型的標(biāo)簽非常簡(jiǎn)單声怔,用 -a (譯注:取 annotated 的首字母)指定標(biāo)簽名字即可:

    $ git tag -a v1.4 -m 'my version 1.4'
    $ git tag
    v0.1
    v1.3
    v1.4
    

其中: -m 選項(xiàng)則指定了對(duì)應(yīng)的標(biāo)簽說(shuō)明,Git 會(huì)將此說(shuō)明一同保存在標(biāo)簽對(duì)象中舱呻。如果沒(méi)有給出該選項(xiàng)醋火,Git 會(huì)啟動(dòng)文本編輯軟件供你輸入標(biāo)簽說(shuō)明。

  1. 顯示標(biāo)簽
    可以使用 git show 命令查看相應(yīng)標(biāo)簽的版本信息箱吕,并連同顯示打標(biāo)簽時(shí)的提交對(duì)象芥驳。

    $ git show v1.4
    
  2. 簽署標(biāo)簽
    如果你有自己的私鑰,還可以用 GPG 來(lái)簽署標(biāo)簽殖氏,只需要把之前的 -a 改為 -s (譯注: 取 signed 的首字母)即可:

    $ git tag -s v1.5 -m 'my signed 1.5 tag'
    
  3. 輕量級(jí)標(biāo)簽
    輕量級(jí)標(biāo)簽實(shí)際上就是一個(gè)保存著對(duì)應(yīng)提交對(duì)象的校驗(yàn)和信息的文件晚树。要?jiǎng)?chuàng)建這樣的標(biāo)簽,一個(gè) -a雅采,-s-m選項(xiàng)都不用爵憎,直接給出標(biāo)簽名字即可。

    $ git tag v1.4-lw
    $ git tag
    v0.1
    v1.3
    v1.4
    v1.4-lw
    v1.5
    
  4. 驗(yàn)證標(biāo)簽
    可以使用 git tag -v [tag-name] (譯注:取 verify 的首字母)的方式驗(yàn)證已經(jīng)簽署的標(biāo)簽婚瓜。此命令會(huì)調(diào)用 GPG 來(lái)驗(yàn)證簽名宝鼓,所以你需要有簽署者的公鑰,存放在 keyring 中巴刻,才能驗(yàn)證愚铡。

  5. 后期加注標(biāo)簽
    你甚至可以在后期對(duì)早先的某次提交加注標(biāo)簽。比如在下面展示的提交歷史中:

    $ git log --pretty=oneline
    15027957951b64cf874c3557a0f3547bd83b3ff6 Merge branch 'experiment'
    a6b4c97498bd301d84096da251c98a07c7723e65 beginning write support
    0d52aaab4479697da7686c15f77a3d64d9165190 one more thing
    6d52a271eda8725415634dd79daabbc4d9b6008e Merge branch 'experiment'
    0b7434d86859cc7b8c3d5e1dddfed66ff742fcbc added a commit function
    

    我們忘了在提交 “updated rakefile” 后為此項(xiàng)目打上版本號(hào) v1.2胡陪,沒(méi)關(guān)系沥寥,現(xiàn)在也能做。只要在打標(biāo)簽的時(shí)候跟上對(duì)應(yīng)提交對(duì)象的校驗(yàn)和(或前幾位字符)即可

    $ git tag -a v1.2 9fceb02
    

    可以看到我們已經(jīng)補(bǔ)上了標(biāo)簽:

    $ git tag
    v0.1
    v1.2
    v1.3
    v1.4
    v1.4-lw
    v1.5
    
    $ git show v1.2
    tag v1.2
    Tagger: Scott Chacon <schacon@gee-mail.com>
    Date:   Mon Feb 9 15:32:16 2009 -0800
    
    version 1.2
    commit 9fceb02d0ae598e95dc970b74767f19372d61af8
    Author: Magnus Chacon <mchacon@gee-mail.com>
    Date:   Sun Apr 27 20:43:35 2008 -0700
    
  6. 分享標(biāo)簽

    默認(rèn)情況下柠座,git push 并不會(huì)把標(biāo)簽傳送到遠(yuǎn)端服務(wù)器上邑雅,只有通過(guò)顯式命令才能分享標(biāo)簽到遠(yuǎn)端倉(cāng)庫(kù)。其命令格式如同推送分支妈经,運(yùn)行 git push origin [tagname] 即可:

    $ git push origin v1.5
    Counting objects: 50, done.
    Compressing objects: 100% (38/38), done.
    Writing objects: 100% (44/44), 4.56 KiB, done.
    Total 44 (delta 18), reused 8 (delta 1)
    To git@github.com:schacon/simplegit.git
    * [new tag]         v1.5 -> v1.5
    

    如果要一次推送所有本地新增的標(biāo)簽上去淮野,可以使用 --tags 選項(xiàng):

    $ git push origin --tags
    Counting objects: 50, done.
    Compressing objects: 100% (38/38), done.
    Writing objects: 100% (44/44), 4.56 KiB, done.
    Total 44 (delta 18), reused 8 (delta 1)
    To git@github.com:schacon/simplegit.git
     * [new tag]         v0.1 -> v0.1
     * [new tag]         v1.2 -> v1.2
     * [new tag]         v1.4 -> v1.4
     * [new tag]         v1.4-lw -> v1.4-lw
     * [new tag]         v1.5 -> v1.5
    

    git push 完代碼

    git push tag標(biāo)簽

    現(xiàn)在,其他人克隆共享倉(cāng)庫(kù)或拉取數(shù)據(jù)同步后吹泡,也會(huì)看到這些標(biāo)簽骤星。

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市爆哑,隨后出現(xiàn)的幾起案子洞难,更是在濱河造成了極大的恐慌,老刑警劉巖泪漂,帶你破解...
    沈念sama閱讀 218,036評(píng)論 6 506
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件廊营,死亡現(xiàn)場(chǎng)離奇詭異歪泳,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī)露筒,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 93,046評(píng)論 3 395
  • 文/潘曉璐 我一進(jìn)店門呐伞,熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人慎式,你說(shuō)我怎么就攤上這事伶氢。” “怎么了瘪吏?”我有些...
    開(kāi)封第一講書人閱讀 164,411評(píng)論 0 354
  • 文/不壞的土叔 我叫張陵癣防,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我掌眠,道長(zhǎng)蕾盯,這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書人閱讀 58,622評(píng)論 1 293
  • 正文 為了忘掉前任蓝丙,我火速辦了婚禮级遭,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘渺尘。我一直安慰自己挫鸽,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 67,661評(píng)論 6 392
  • 文/花漫 我一把揭開(kāi)白布鸥跟。 她就那樣靜靜地躺著丢郊,像睡著了一般。 火紅的嫁衣襯著肌膚如雪医咨。 梳的紋絲不亂的頭發(fā)上枫匾,一...
    開(kāi)封第一講書人閱讀 51,521評(píng)論 1 304
  • 那天,我揣著相機(jī)與錄音拟淮,去河邊找鬼婿牍。 笑死,一個(gè)胖子當(dāng)著我的面吹牛惩歉,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播俏蛮,決...
    沈念sama閱讀 40,288評(píng)論 3 418
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼撑蚌,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了搏屑?” 一聲冷哼從身側(cè)響起争涌,我...
    開(kāi)封第一講書人閱讀 39,200評(píng)論 0 276
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎辣恋,沒(méi)想到半個(gè)月后亮垫,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體模软,經(jīng)...
    沈念sama閱讀 45,644評(píng)論 1 314
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 37,837評(píng)論 3 336
  • 正文 我和宋清朗相戀三年饮潦,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了燃异。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 39,953評(píng)論 1 348
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡继蜡,死狀恐怖回俐,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情稀并,我是刑警寧澤仅颇,帶...
    沈念sama閱讀 35,673評(píng)論 5 346
  • 正文 年R本政府宣布,位于F島的核電站碘举,受9級(jí)特大地震影響忘瓦,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜引颈,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 41,281評(píng)論 3 329
  • 文/蒙蒙 一耕皮、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧线欲,春花似錦明场、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書人閱讀 31,889評(píng)論 0 22
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至趴泌,卻和暖如春舟舒,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背嗜憔。 一陣腳步聲響...
    開(kāi)封第一講書人閱讀 33,011評(píng)論 1 269
  • 我被黑心中介騙來(lái)泰國(guó)打工秃励, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人吉捶。 一個(gè)月前我還...
    沈念sama閱讀 48,119評(píng)論 3 370
  • 正文 我出身青樓夺鲜,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親呐舔。 傳聞我的和親對(duì)象是個(gè)殘疾皇子币励,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 44,901評(píng)論 2 355