标签(linux): git

笔者Q:972581034 交流群:605799367。有任何疑问可与笔者或加群交流

git 的四个区域

1103448-20170816160726709-1204298562.png

四种状态

1103448-20170816162322646-1786376613.png

常用命令

git add                #加入暂存(索引区)
git status            #查看状态
git status -s        #状态概览
git diff                  #尚未暂存的文件
git diff --staged  #暂存区文件
git commit          #提交更新
git reset              #回滚
git rm                  #从版本库中移除
git rm --cached README        #从暂存区中移除
git mv                 #相当于mv git rm git add
查看历史版本
[root@git test]# git log
commit 1cf6888d97b0a361a3daed01a06c67936bc4f241
Author: chentiangang <chentiangang@yoho8.com>
Date:   Thu Aug 17 23:49:27 2017 +0800

    first index:v2

commit 145b100cd0e07a9e59e15cf71aad3338ed8a57a6
Author: chentiangang <chentiangang@yoho8.com>
Date:   Thu Aug 17 23:42:32 2017 +0800

    index.html
创建一个新的文件
[root@git test]# echo "news" > news.html
[root@git test]# ls
index.html  news.html  pay.html
[root@git test]# git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

    new file:   pay.html

Untracked files:
  (use "git add <file>..." to include in what will be committed)

    news.html
删除刚才提交到暂存区的文件
[root@git test]# git rm --cached pay.html
rm 'pay.html'
[root@git test]# git status 
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

    news.html
    pay.html

nothing added to commit but untracked files present (use "git add" to track)

转载于:https://www.cnblogs.com/Csir/p/7373879.html

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐