git status简单用法

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

[root@localhost gender]# git status
# On branch master
# Your branch is ahead of 'origin/master'by 1 commit.
#
# Changed but not updated:
#  (use "git add <file>..." to update what will becommitted)
#  (use "git checkout -- <file>..." to discard changes inworking directory)
#
#       modified:   server.c
#
no changes added to commit (use "gitadd" and/or "git commit -a")
[root@localhost gender]#

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

[root@localhost gender]# git add server.c
[root@localhost gender]# git status
# On branch master
# Changes to be committed:
#  (use "git reset HEAD <file>..." to unstage)
#
#       modified:   server.c
#
[root@localhost gender]#

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

执行如下:

[root@localhost gender]# git commit -m"no modify"
(此处省去95个字)
 [root@localhost gender]# git status
# On branch master
# Your branch is ahead of 'origin/master'by 1 commit.
#
nothing to commit (working directory clean)
[root@localhost gender]#

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


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

  • 2
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值