git status简单用法

 

git status简单用法

  8390人阅读  评论(0)  收藏  举报
  分类:

Git status可以用来查看仓库的状态,这个命令是一个很有用的命令,在用GIT的过程中,会出现各种意想不到的情况,原因是我们反复提交和修改。git status可以帮助我们快速的知道当前的GIT状态。命令如下:

[html]  view plain  copy
 print ?
  1. [root@localhost gender]# git status  
  2. # On branch master  
  3. # Your branch is ahead of 'origin/master'by 1 commit.  
  4. #  
  5. # Changed but not updated:  
  6. #  (use "git add <file>..." to update what will becommitted)  
  7. #  (use "git checkout -- <file>..." to discard changes inworking directory)  
  8. #  
  9. #       modified:   server.c  
  10. #  
  11. no changes added to commit (use "gitadd" and/or "git commit -a")  
  12. [root@localhost gender]#  

上面的输出提示你下面的信息,Changedbut not updated,表示我们改动了server.c但是没有更新快照,此时我们应该执行git add server.c(或者git add .来更新快照)。执行如下:

[html]  view plain  copy
 print ?
  1. [root@localhost gender]# git add server.c  
  2. [root@localhost gender]# git status  
  3. # On branch master  
  4. # Changes to be committed:  
  5. #  (use "git reset HEAD <file>..." to unstage)  
  6. #  
  7. #       modified:   server.c  
  8. #  
  9. [root@localhost gender]#  

又有事了,输出的Changes to becommitted表示我们的改动已经准备好了,随时可以提交,我们只要用git commit命令提交就可以了。

执行如下:

[html]  view plain  copy
 print ?
  1. [root@localhost gender]# git commit -m"no modify"  
  2. (此处省去95个字)  
  3.  [root@localhost gender]# git status  
  4. # On branch master  
  5. # Your branch is ahead of 'origin/master'by 1 commit.  
  6. #  
  7. nothing to commit (working directory clean)  
  8. [root@localhost gender]#  

现在就是很干净的状态了。


有一个问题需要注意,就是如果Changedbut not updated之后,执行git add ./ ,但之后又修改了这个文件,那么会同时出现Changedbut not updated和Changes to becommitted。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值