Usually when I have to commit my daily work I use:
git add *
git commit -m "my commit message"
git push origin master
This commands are very base. But I've notice that deleted file are not deleted from my remote repo. In fact if I delete a generic file "example.txt" (on my local folder)after push changes on Github the file still remain.
Tecnically with git add *
the deleted files should be recognized, or not?
How can I remove from my remote repo the deleted file?
Thanks
To add a single file to the commit that you've deleted, you can do git add what/the/path/to/the/file/used/to/be . This is helpful when you have one or two deletions to add, but doesn't add a batch of deletions in one command.
It means that the file was removed from the filesystem but it was not deleted from the index just yet. In order for the changes to be effective, you will have to commit your changes and push them to your remote repository.
Using git rm <deleted-filename> and git add <deleted-filename>. Your branch is up-to-date with 'origin/master'. It will stage the deleted file, and followed by git commit and git push will remove the file from the repository.
git add
does not by default record file deletions. Passing the --all
flag will tell it to also look for deleted files.
As Tim Biegeleisen suggested, it is worth combining the use of git status
to see the changes in your working directory, and then using git add <filename>
to add them one by one. This way you have more visibility and control over what you add to the staging area. You can also use git add <directory>
to add a whole directory at once, or git add -i
which will ask git to walk you through each file change and let you choose to stage it or ignore it.
git add *
does not track the deleted files it only includes modified or new added files. You have to use
$ git add . --all
to track all files (deleted files included)
Refs: docs
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