Git add
- Say I want to add
file01
, but accidentally add file01
and file02
.
$ git add file01 file02
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file01
new file: file02
Untracked files:
(use "git add <file>..." to include in what will be committed)
file03
git reset
is required:
git reset filename.txt
Will remove a file named filename.txt from the current index, the "about to be committed" area, without changing anything else.
git reset file02
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file01
Untracked files:
(use "git add <file>..." to include in what will be committed)
file02
file03
- Say Say I don't want to add any file, but accidentally add all the files.
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
file01
file02
file03
nothing added to commit but untracked files present (use "git add"
to track)
git add *
$ git status
On branch master
No commits yet
Changes to be committed:
(use "git rm --cached <file>..." to unstage)
new file: file01
new file: file02
new file: file03
$ git reset
No dot(.) after reset
$ git status
On branch master
No commits yet
Untracked files:
(use "git add <file>..." to include in what will be committed)
file01
file02
file03
nothing added to commit but untracked files present (use "git add"
to track)