From the course: Git Essential Training

Unlock this course with a free trial

Join today to access over 24,700 courses taught by industry experts.

Delete files

Delete files

- [Instructor] We've already added files and made changes to existing ones, but what happens if we delete a file? Let's find out. Let's go back to our repository. I am going to delete Example02.md. I'll press Delete and confirm that I want to delete it. Let's use git status to see how Git responds to this. It shows that the file has been deleted. If we want this change to follow through into the Git repository, we have to commit it like we would with any other changes. So, I'll stage it using git add . and then commit it with a message like Removes Example02.md. Git now shows that one file was changed and everything inside it was deleted. Now, let's push. And now, I can check my remote repository. When I refresh it, I see that Example02 has been deleted as well. I can still see the commit message though, and that's the important part. Even though the file has been deleted, Git still remembers it. It is still part of those old snapshots in the Git history. This means it's possible to…

Contents