Git添加提交及查看状态

  • 查看工作区暂存区状态
git status 
  • 将工作区的 新建/修改 提交到暂存区
git add 
  • 移除暂存区的文件
git rm --cached 文件名 
  • 将暂存区文件提交到本地库
git commit 文件名
git commit  -m "本次提交说明“ 文件名
  • 查看日志
显示日志
git log
以一行的形式显示日志
git log --pretty=oneline 

git log --oneline

git reflog

示例

$ git status
On branch master //在主分支上

No commits yet //尚未提交

nothing to commit (create/copy files and use "git add" to track)//没有什么东西可以提交

创建一个txt文件查看状态,使用git add提交文件到暂存区 ,除暂存区文件

$ vim good.txt

$ git status
On branch master

No commits yet

Untracked files: //未追踪的文件
  (use "git add <file>..." to include in what will be committed)
        good.txt

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

//将文件提交到暂存区
$ git add good.txt



//将文件从暂存区移除
$ git rm --cached good.txt
rm 'good.txt'



$ git commit good.txt //提交文件到本地库 提交进入以下界面输入本次提交信息
// :set nu显示行号
// i 进入编辑模式
// esc退出编辑模式
// :wq保存并退出

  # Please enter the commit message for your changes. Lines starting
  # with '#' will be ignored, and an empty message aborts the commit.
  #
  # On branch master
  #
  # Initial commit
  #
  # Changes to be committed:
  #       new file:   good.txt
  #

//保存退出返回以下内容
warning: LF will be replaced by CRLF in good.txt.
The file will have its original line endings in your working directory
[master (root-commit) eb9f1b9] My first commit.new file good`  //本次提交id 、次数、提交信息 
 1 file changed, 3 insertions(+) //修改你文件个数 和行数
 create mode 100644 good.txt


©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 以下笔记主要参考gitgot,大致了解git使用和原理。 第一部分我们从个人的视角去研究如何用好Git,并且揭示G...
    carolwhite阅读 2,435评论 0 1
  • 一、基本概念: 注:对于git的分布式概念及其优点,不重复说明,自己百度或谷歌。本文中涉及到指令前面有$的,在cm...
    大厂offer阅读 1,456评论 0 3
  • Git 是目前最流行的分布式版本控制系统之一。 版本控制指的是,记录每次版本变更的内容和时间等细节,保留各版本之间...
    神齐阅读 1,467评论 0 7
  • 第一部分是文档,为了日后查看方便放到了前边[可能敲错了,详见阮一峰老师的文章]http://www.ruanyif...
    白璞1024阅读 1,042评论 0 49
  • git第一天记录: git config --global user.name "maxwelldu" ...
    女汉子的眼泪是钻石i阅读 401评论 0 0