您好,欢迎来到二三四教育网。
搜索
您的当前位置:首页Git add & Git add undo

Git add & Git add undo

来源:二三四教育网
  • 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)
    

Copyright © 2019- how234.cn 版权所有 赣ICP备2023008801号-2

违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com

本站由北京市万商天勤律师事务所王兴未律师提供法律服务