Git & GitHub · Lesson 19 of 144
Adding, Removing, Renaming
Git rm and git mv.
Projects change shape. You'll delete files, and rename them. Git needs to know about those changes too, and it has two small commands to help.

- Projects change shape
- Files get deleted and renamed
- Git has commands for both
Deleting a file
To delete a file and tell Git at the same time, use git r m. Here we remove the old about page. Status shows the deletion is already staged, in green. Commit it, and the file is gone from the project. But don't worry, it still lives in the history, in older commits.
git
git rm about.html rm 'about.html' git status --short D about.html git commit -m "Remove about page" [main 0bf0ddf] Remove about page 1 file changed, 1 deletion(-) delete mode 100644 about.html
Renaming a file
To rename, use git m v, for move. The old name, then the new name. Here, style dot CSS becomes main dot CSS. Status shows R, for renamed. Commit it, and the rename is saved.
git
git mv style.css main.css git status --short R style.css -> main.css git commit -m "Rename style.css to main.css" [main d66776c] Rename style.css to main.css 1 file changed, 0 insertions(+), 0 deletions(-) rename style.css => main.css (100%)
Summary
git r m deletes a file, and git m v renames it, and both stage the change for you. Next, a shortcut for committing changed files.
Key takeaways- git rm <file>
- git mv <old> <new>
- Old versions stay in history
Next up: The Commit Shortcut — git commit -am