Search code examples
gitstaging

How to prevent git from staging deleted files with git add .?


I was trying to stage multiple files for a react-app I'm building and after staging the project files with git add . I then run git status and it shows that I staged files that I had previously deleted. I found out that git changed and that git add . stages deleted files now so I'm looking for a command that will only stage current files (and not these deleted files).


Solution

  • git add --ignore-removal .
    

    --ignore-removal

    Update the index by adding new files that are unknown to the index and files modified in the working tree, but ignore files that have been removed from the working tree.

    git-add Documentation