git add
git add 跟踪新文件
一下git操作记录,用vim新建一个文件,hi.txt,使用git add跟踪新建的文件
Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$ git statusOn branch masterUntracked files: (use "git add..." to include in what will be committed) hi.txtnothing added to commit but untracked files present (use "git add" to track)Lenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$ git add hi.txtLenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$ git statusOn branch masterChanges to be committed: (use "git reset HEAD ..." to unstage) new file: hi.txtLenovo@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 statusOn branch masternothing to commit, working directory cleanLenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$ vim hello.txtLenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$ git statusOn branch masterChanges not staged for commit: (use "git add..." to update what will be committed) (use "git checkout -- ..." to discard changes in working directory) modified: hello.txtno 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 masterChanges not staged for commit: modified: hello.txtno changes added to commitLenovo@LENOVO-PC /e/HelloGit3/MyDemo2 (master)$
git add 用于合并时把有冲突的文件标记为已解决状态
无
===========END===========