There is a tracked file that we do not need anymore. I deleted the file on my local repository. So what are the git commands to write in order for the action to be effective on the remote repository ?
1 Answer
Untrack the file
If you don't want git to track a file you have to can untrack it with
git rm --cached filename Then you will need to commit the changes locally with:
git commit After that you can push the changes to the remote with:
git push Delete the file
If you want to delete a file, simply remove it from the repo.
Add the changes with:
git add -A You can check the changes with git status:
On branch main Your branch is up to date with 'origin/main'. Changes to be committed: (use "git restore --staged <file>..." to unstage) deleted: file.md Then you can commit your changes with:
git commit -m "Removed the file" To push the changes on the remote:
git push 5 Comments
pheromix
my goal is not to untrack the file, but really make the deletion of the file to be passed on at the remote repo : I want the file to be deleted also at the remote repo.
pheromix
do I have to make a
git add deleted_filename before git commit ?pheromix
no :
git status gives Changes not staged for commit -> deleted : path/to/the/deleted_filenameAtropo
Add the changes with
git add -A pheromix
it is
git add -A filename but not just git add -A
git push?