查看文件状态与跟踪新文件(git status/add)

查看当前文件状态

使用git status查看文件状态,如果是空仓库,执行结果如下

$ git status
On branch master

No commits yet

nothing to commit (create/copy files and use "git add" to track)

如果我们加入一个新文件main.c

$ git status
On branch master

No commits yet

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

        main.c

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

可以看到,main.c处于未跟踪状态,未跟踪状态的文件不会包含到下一次的提交范围中。git也不会主动跟踪这些文件,需要你明确告诉git需要跟踪。

跟踪新文件

通过git add (file)命令让Git跟踪心得文件,例如需要跟踪所有的.c文件

$ git add *.c

此时再次查看文件状态

$ git status
On branch master

No commits yet

Changes to be committed:
  (use "git rm --cached <file>..." to unstage)

        new file:   main.c

可以看到main.c已经被加入到暂存区等待提交。git add可以接受文件或目录路径名作为参数,如果提供的参数是目录,该命令会递归地天下该目录下的所有文件。

转载于:https://www.cnblogs.com/velscode/p/10584745.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值