How To Remove File From Git. Assuming it was a.env file, 3. If you want to ignore a tracked file without deleting it, run this command on the command line:

Using the git reset head <<strong>file</strong>> method. If you do git status now, git says there is a file that is not staged for commit and it has been deleted from the local copy of the repo. To remove a file both from the git repository and the filesystem, you can use git rm without any parameters (except for the file's name, of course):