Normal file operations like deleting, moving, changing file name can be done in git.
A tracked file can be removed liked below.
$ git rm LICENSE rm 'LICENSE' $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) deleted: LICENSE
After remove operation and commit the file will be not tracked and exist for the future commits but exist in the history.
If the file is edited we need to force removal with the following command.
$ git rm README.md error: the following file has local modifications: README.md (use --cached to keep the file, or -f to force removal) $ git rm -f README.md rm 'README.md'
rmremoves the specified file
-fforces for removal even if the file is edited
Unlike other vcs Git do not tracks files movements for reguler movement. To make Git aware of the movement
mv is used.
$ git mv main.py main2.py $ git status On branch master Changes to be committed: (use "git reset HEAD <file>..." to unstage) renamed: main.py -> main2.py
mvmoves main.py to main2.py