git-ftp icon indicating copy to clipboard operation
git-ftp copied to clipboard

Delete file from index SHOULD NOT delete file on FTP

Open Janghou opened this issue 14 years ago • 10 comments

I removed a file from the index git rm --cached file and it was deleted on FTP, while it shouldn't.

--cache Use this option to unstage and remove paths only from the index. Working tree files, whether modified or not, will be left alone.

Janghou avatar Jan 26 '11 13:01 Janghou

i disagree. git rm --cached removed a file from the index. the remote files on your ftp server are a copy of the index, not your local directory. so it's doing exactly what it should be.

kbjr avatar Jan 26 '11 15:01 kbjr

Remote files aren't necessarily a copy of the index. There can be uploaded files by the user, or explicitly remotely changed files (config, htaccess) Therefore I would see the FTP as a kind of a remote working tree.

Consider this use-case: .htaccess was included by accident. But it should be ignored. How can we correct that?

Adding it to .gitignore doesn't help when it's already tracked. You have to remove it from the index to have it untracked, but IMHO it shouldn't be deleted on FTP.

Dunno if python-git can see the difference between a removed file and index-removed only file, that leaves working tree files alone.

Janghou avatar Jan 26 '11 17:01 Janghou

Closed it by accident, can't see a way to reopen it.

Janghou avatar Jan 26 '11 18:01 Janghou

perhaps an option could be added to the config file or some form of git-ftp only .gitignore file.

kbjr avatar Jan 26 '11 18:01 kbjr

We should be diffing against HEAD, which is not the index, so this is pretty mysterious. I'll take a look.

ezyang avatar Jan 26 '11 20:01 ezyang

I can't reproduce, so I'll need explicit instructions.

W.r.t. to not uploading certain files, sure, that's a reasonable feature request. Please open another issue?

ezyang avatar Jan 26 '11 20:01 ezyang

I will look it to it later, and see if I can make a reproducible example.

Janghou avatar Jan 27 '11 10:01 Janghou

Can easily reproduce. Create a repository with 2 files, add one to ignorelist, remove it from cache, it will be deleted on FTP.

By maybe that's default operation, because it's removed from the repository, and git rm --cache is only a local command to leave it in local working directory.

I don't know if the repository (HEAD, index) has any clue if a a git rm file or git rm --cache file command has been given. If not there isn't much we can do, and my problem wasn't an issue but a lack of knowledge about git.

Janghou avatar Jan 31 '11 11:01 Janghou

It's still difficult to parse what you're saying. Can you write down the precise commands you are using?

ezyang avatar Jan 31 '11 16:01 ezyang

Sorry, a bit late.

1 create new dir html with 2 files index.php and .htaccess 2 cd .. git clone --bare html html.git 3 scp -r html.git server:/home/git-reps 4 mv html html_bu 5 git clone server:/home/git-reps/html.git 6 rm -rf html_bu 7 set ftp data in: server:/home/git-reps/html/ftpdata 8 git push, everything will be ftp'd to ftpserver

I need a different .htaccess locally then on the ftp server. Of course changing .htaccess will change .htacces on ftp-server. So I want to stop tracking .htaccess: I add it to .gitignore Changes to .htaccess will still be tracked cause it's still in the index. So i remove it from the index: git rm --cached .htaccess Now .htaccess is also removed from the ftp-server next push, while I think it shouldn't, at least i don't want it to happen. ;)

But I don't know if the index, or to be specific the post-update hook can make a difference between a git rm and a git rm --cache command after it's pushed.

Janghou avatar Feb 17 '11 12:02 Janghou