I'm trying to learn to use Git, and I kind of get the basics of pulling and pushing etc, but I'm confused on deletions.
This is what I've done (with fortrabbit and laravel):
- Created a Laravel Project
- run
git init .
in the project folder - run
git remote add origin ...
- run
git add -A
- run
git commit -am 'Initial'
- run
git push -u origin master
Now my local copy matches my remote copy.
I now want to delete a file, so I create a test file:
- run
touch testfile1.php
I add the file, commit it then push it. Now I have the test file locally and remotely.
The problem is deleting it. This question is in 2 parts:
Reading this SO question: How can I delete a file from git repo? it says I should do:
git rm testfile1.php
git commit -m 'deleted file'
git push origin master
However that only deletes the local copy. The remote copy is still there!
If I delete it from my local copy, how does it get deleted from the remote version too?
My second question is, if someone else has a copy, how do they know I've deleted the file? If they push their copy back to the remote one, won't it just re-add the deleted file?
Any help is appreciated.
EDIT
This is the output of the git rm
command, and the remote version after the command:
The first image is me typing the git rm testfile1.php
file. It then outputs rm testfile1.php
and returns to the prompt. When I SSH back into the remote version, the testfile`.php is still there :/
Another Edit
I've just been reading some help articles provided by Fortrabbit, primarily, this one: http://help.fortrabbit.com/git#toc-behind-the-scenes
It says the it overwrites, but doesn't delete.
Would this be the reason why git says it's up to date, but the file is still in the web root? If so, for what reason could there possibly be not to delete a file that I've asked to be deleted?!