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===========