Should I add deleted files to stage area?

I’m confused about Git.

I know that changed files or new files must be added to stage area, but what about deleted files? Should I add deleted files to the staging area too?

  • Branch autocompletion does not work with git alias for push
  • Gist.github prolog syntax highlight
  • Can't access AWS CodeCommit with SSH
  • How do I get a unique list of files modified in a repository within a range of commits in Git?
  • multiple git repositories cloned into the same directory
  • Is is possible to use to use git-flow (or vanilla git), to have different set of (build) files on master & develop branches?
  • Here is a hypothetical scenario:


    If I remove/delete controller_1.php from my myproject-dir/app/controller/, should I add this file to next commit?

  • Are all files within a C# Project necessary to put under version control?
  • deploying from github to linux server using ssh but Permission denied (publickey). PHP script
  • Can I use mSysGit and Cygwin's git?
  • How do I Add a A Package To Buildroot Which Is Available In A Git Repository?
  • How is git push through network working? (proxy)
  • GitHub: Is there a way to programmatically file an issue?
  • One Solution collect form web for “Should I add deleted files to stage area?”

    You should think about the staging area more as something were you add changes to. So adding a file to the repository is a change where you add a file. Modifying a file in the repository is a change where you modify a file. And deleting a file from the repository is a change where you delete the file.

    So yes, for the repository to recognize that the file is actually removed from the repository in a commit, you need to add the file removal to the index.

    You can do that using git rm:

    git rm path/to/file

    If you—for whatever reason—want to keep the file on the disk when removing it from the repository, you can use the --cached option to keep it.

    git rm --cached path/to/file

    If the file is already physically deleted from the disk, you can still use git rm as above to add the removal to the index. You can also use the update capability of git add to discover updates to tracked files automatically and stage them:

    git add -u .

    This will add all changes (additions, modifications and file removals) of all tracked files in the current directory. If you leave off the dot at the end, it applies to the whole repository (so you have less control over it).

    Git Baby is a git and github fan, let's start git clone.