Git版本库的状态

1.修改文件

  修改仓库里的文件readme.txt.

$ vim readme.txt

   修改后的文件内容如下:

Welcome to git.
Git is a version control system.
Git is free.

    运行git status 命令查看仓库的状态。

$ git status
 On branch master
 Changed but not updated:
   (use "git add <file>..." to update what will be committed)
   (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   readme.txt

no changes added to commit (use "git add" and/or "git commit -a")

    上述结果表示,readme.txt被修改了,但是还没有准备提交。

2.准备提交

    运行git add命令执行提交的第一步。

$ git add readme.txt

    运行git status 命令查看仓库的状态。

$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

  modified:   readme.txt

    上述结果表示,将要被提交的修改包括readme.txt。

3.提交

  运行git commit命令执行提交的第二步。

$ git commit -m "modify file"
[master 4e22fba] modify file
 1 files changed, 1 insertions(+), 0 deletions(-)

   运行git status 命令查看仓库的状态。

$ git status
On branch master
nothing to commit (working directory clean)

    现在没有需要提交的修改了,工作目录是干净的。

猜你喜欢

转载自blog.csdn.net/liyazhen2011/article/details/83445364