On Sat, Dec 3, 2016 at 5:49 PM, Johannes Sixt <j6t@xxxxxxxx> wrote: > Am 03.12.2016 um 06:04 schrieb Julian de Bhal: >> >> If you `git add new_file; git reset --hard`, new_file is gone forever. > > AFAIC, this is a feature ;-) I occasionally use it to remove a file when I > already have git-gui in front of me. Then it's often less convenient to type > the path in a shell, or to pointy-click around in a file browser. Yeah, I'm conscious that it would be a change in behaviour and would almost certainly break things in the wild. On the other hand, `rm` deletes perfectly well, but there's no good way to recover the lost files after the fact. You can take some precautions after you've been bitten, but git usually means never saying "you should have". >> git add new_file >> [...] >> git reset --hard # decided copy from backed up diff >> # boom. new_file is gone forever > > ... it is not. The file is still among the dangling blobs in the repository > until you clean it up with 'git gc'. Use 'git fsck --lost-found': Thank you so much! Super glad to be wrong here. Cheers, Jules On Sat, Dec 3, 2016 at 5:49 PM, Johannes Sixt <j6t@xxxxxxxx> wrote: > Am 03.12.2016 um 06:04 schrieb Julian de Bhal: >> >> If you `git add new_file; git reset --hard`, new_file is gone forever. > > > AFAIC, this is a feature ;-) I occasionally use it to remove a file when I > already have git-gui in front of me. Then it's often less convenient to type > the path in a shell, or to pointy-click around in a file browser. > >> git add new_file > > > Because of this ... > >> git add -p # also not necessary, but distracting >> git reset --hard # decided copy from backed up diff >> # boom. new_file is gone forever > > > ... it is not. The file is still among the dangling blobs in the repository > until you clean it up with 'git gc'. Use 'git fsck --lost-found': > > --lost-found > > Write dangling objects into .git/lost-found/commit/ or > .git/lost-found/other/, depending on type. If the object is a blob, the > contents are written into the file, rather than its object name. > > -- Hannes >