Reputation: 45
Is there any difference between:
git rm name.txt
git commit -m "message"
and
#delete the file name.txt normally with the file manager (right-click and delete) and erasign the trash
git add .
git commit -m "message"
Upvotes: 0
Views: 96
Reputation: 78623
If the only change you're making to that folder is the removal of that file, then no, there is no difference in the end result. Both will remove that file from the index and the working directory. (git
will do it for you in the git rm
case, while you will have done it yourself in the second.)
However if you have made any other changes in the working directory, then those changes will also be staged. This includes staging files that were previously untracked. This can be quite annoying as you may accidentally include build output, or perhaps your editor creates swapfiles next to the files it's editing?
For that reason, I recommend the explicit git rm filename
over rm filename && git add .
.
Upvotes: 3
Reputation: 7074
Using git rm
will remove the file from the repository index and will automatically be included with your next commit. By deleting the file manually, you will need to still add the deleted file so that git understands it has been deleted. The rm
command just does it in one step.
Upvotes: 3