When I delete a file (or rename it) by using mv
, rm
or some other facility, the file shows as deleted when I do git status
:
# Changes not staged for commit:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# deleted: ../src/main/..../myFile.java
Before creating a commit, it is cumbersome to do git rm <file>
for each file, particularly as there is no auto-completion in the terminal for a file which isn't there.
Is there a shorter way to remove the deleted files from the set of files tracked by git?
Thanks
The "rm" command helps you to remove files from a Git repository. It allows you to not only delete a file from the repository, but also - if you wish - from the filesystem. Deleting a file from the filesystem can of course easily be done in many other applications, e.g. a text editor, IDE or file browser.
Listing all the deleted files in all of git history can be done by combining git log with --diff-filter . The log gives you lots of options to show different bits of information about the commit that happened at that point.
Git keeps a log of all the changes made to files within a repository. You can restore a file that you have deleted since a previous commit by using the git checkout command. This command lets you navigate to a previous point in your repository's history.
Deleting files by right-clicking them sends them directly to the Recycle Bin. To permanently delete all the files in your Recycling Bin, minimize all your open windows, right-click the Recycle Bin on your desktop, and select Empty Recycle Bin.
I believe git add -u
will do what you wish, from the documentation:
-u
--update
Only match <filepattern> against already tracked files in the index
rather than the working tree. That means that it will never stage new
files, but that it will stage modified new contents of tracked files
and that it will remove files from the index if the corresponding file
in the working tree have been removed.
Reference: http://git-scm.com/docs/git-add
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With