git add

git add

 

git add 跟踪新文件

一下git操作记录,用vim新建一个文件,hi.txt,使用git add跟踪新建的文件

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git status
On branch master
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        hi.txt

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

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git add hi.txt

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git status
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        new file:   hi.txt


Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$

 

git add 暂存已修改的文件

如下的git操作记录,就是因为没有把修改的文件放到暂存区域,从而有Changes not staged for commit,需要对修改的文件使用git add 放入到暂存区才能使用git commit提交。

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git status
On branch master
nothing to commit, working directory clean

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ vim hello.txt

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git status
On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified:   hello.txt

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

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$ git commit -m "hello"
On branch master
Changes not staged for commit:
        modified:   hello.txt

no changes added to commit

Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)
$

 

git add 用于合并时把有冲突的文件标记为已解决状态

===========END===========

转载于:https://my.oschina.net/xinxingegeya/blog/424093

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值