美文网首页Git
Git add & Git add undo

Git add & Git add undo

作者: JaedenKil | 来源:发表于2018-07-13 14:06 被阅读16次
  • Init a repo
$ touch file01
$ touch file02
$ touch file03
$ 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
    • 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)
    

相关文章

网友评论

    本文标题:Git add & Git add undo

    本文链接:https://www.haomeiwen.com/subject/khrjpftx.html