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 ?
Asked
Active
Viewed 24 times
0

pheromix
- 18,213
- 29
- 88
- 158
-
has deleting the file locally not allowed for staging the deletion for remote?? – Asad Aug 04 '23 at 15:43
-
Are you asking for `git push`? – mkrieger1 Aug 04 '23 at 15:48
-
https://stackoverflow.com/search?q=%5Bgit%5D+delete+file – phd Aug 04 '23 at 16:11
1 Answers
1
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

Atropo
- 12,231
- 6
- 49
- 62
-
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 Aug 04 '23 at 15:55
-
-
-
no : `git status` gives `Changes not staged for commit -> deleted : path/to/the/deleted_filename` – pheromix Aug 04 '23 at 16:10
-
-