Staging Deleted files

Since Git 2.0.0, git add will also stage file deletions. Git 2.0.0 Docs – git-add < pathspec >… Files to add content from. Fileglobs (e.g. *.c) can be given to add all matching files. Also a leading directory name (e.g. dir to add dir/file1 and dir/file2) can be given to update the index to match the current … Read more

How to revert a “git rm -r .”?

Should do it. If you don’t have any uncommitted changes that you care about, then should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn’t work, then save your uncommitted changes with git stash:

How can I delete a file from a Git repository?

Use git rm. If you want to remove the file from the Git repository and the filesystem, use: But if you want to remove the file only from the Git repository and not remove it from the filesystem, use: And to push changes to remote repo

Why are there two ways to unstage a file in Git?

git rm –cached <filePath> does not unstage a file, it actually stages the removal of the file(s) from the repo (assuming it was already committed before) but leaves the file in your working tree (leaving you with an untracked file). git reset — <filePath> will unstage any staged changes for the given file(s). That said, … Read more