How to remove files from git staging area?

后端 未结 14 1126
失恋的感觉
失恋的感觉 2020-11-28 16:53

I made changes to some of my files in my local repo, and then I did git add -A which I think added too many files to the staging area. How can I delete all the

相关标签:
14条回答
  • 2020-11-28 17:28

    use

    git reset HEAD
    

    This will remove all files from staging area

    0 讨论(0)
  • 2020-11-28 17:28

    The best way to undo your file which is already there in the staging area is git reset --hard which brings your staged files to back. Careful now, that will remove staged and unstaged changes.

    0 讨论(0)
  • 2020-11-28 17:30

    It is very simple:

    1. To check the current status of any file in the current dir, whether it is staged or not:

      git status

    2. Staging any files:

      git add . for all files in the current directory

      git add <filename> for specific file

    3. Unstaging the file:

      git restore --staged <filename>

    0 讨论(0)
  • 2020-11-28 17:35

    Use

    git reset
    

    to unstage all the staged files.

    0 讨论(0)
  • 2020-11-28 17:36

    You could use

    git reset HEAD
    

    then add the specific files you want with

    git add [directory/]filename
    
    0 讨论(0)
  • 2020-11-28 17:38

    You can reset the staging area in a few ways:

    1. Reset HEAD and add all necessary files to check-in again as below:

       git reset HEAD ---> removes all files from the staging area
       git add <files, that are required to be committed>
       git commit -m "<commit message>"
       git push 
      
    0 讨论(0)
提交回复
热议问题