As per the subject - if I am maintaining a set of files in a directory and one of them is no longer used then I would do "git rm <name of file>" and then when I commit the file is no longer in the current version of the repository.
I assume however that it would be possible to get back the last (and previous) committed version of the file if I needed ot at some time in the future?
On 30/11/12 15:36, Chris Green wrote:
As per the subject - if I am maintaining a set of files in a directory and one of them is no longer used then I would do "git rm <name of file>" and then when I commit the file is no longer in the current version of the repository.
I assume however that it would be possible to get back the last (and previous) committed version of the file if I needed ot at some time in the future?
man git-rm "git-rm - Remove files from the working tree and from the index"
So they are still in the history and can be recovered using: git checkout <commit> -- <file>
To remove a file completely from history you need to something like what's described in: http://git-scm.com/book/ch6-4.html#The-Nuclear-Option:-filter-branch but even that leaves stuff around for a while so to completely remove a a file immediately you need to do stuff like in: http://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-c...
You do have backups, right? :)
Hope that helps, Mike.
On Fri, Nov 30, 2012 at 07:53:50PM +0000, Michael Dorrington wrote:
On 30/11/12 15:36, Chris Green wrote:
As per the subject - if I am maintaining a set of files in a directory and one of them is no longer used then I would do "git rm <name of file>" and then when I commit the file is no longer in the current version of the repository.
I assume however that it would be possible to get back the last (and previous) committed version of the file if I needed ot at some time in the future?
man git-rm "git-rm - Remove files from the working tree and from the index"
Yes, OK, it's just that as an infrequent user of git telling me that files are removed from "the working tree and from the index" doesn't really give me a warm feeling that I haven't deleted the file completely! :-)
So they are still in the history and can be recovered using: git checkout <commit> -- <file>
Good, that's what I want.
To remove a file completely from history you need to something like what's described in: http://git-scm.com/book/ch6-4.html#The-Nuclear-Option:-filter-branch but even that leaves stuff around for a while so to completely remove a a file immediately you need to do stuff like in: http://stackoverflow.com/questions/872565/remove-sensitive-files-and-their-c...
You do have backups, right? :)
Yes, of course, hourly/daily/weekly incremental backups to another drive on my desktop system and longer term backups to an 'off site' (in the garage, quite a long way away) system.
On 30/11/12 21:03, Chris Green wrote: <snip>
man git-rm "git-rm - Remove files from the working tree and from the index"
Yes, OK, it's just that as an infrequent user of git telling me that files are removed from "the working tree and from the index" doesn't really give me a warm feeling that I haven't deleted the file completely! :-)
LOL. :) But it's "obvious"! ;) The general workflow of git keeps adding to the history (certainly any published history) but if ever you have any doubts about something then it's quick to set up a little test git repo and play with the commands. You could even quite easily clone the git repo of interest and try on the clone.
The Git Pro book is worth at look: http://git-scm.com/book/en/Getting-Started-Git-Basics
Regards, Mike.