On Fri, 29 Jul 2016 16:09:36 -0700 (PDT)
GUGLHUPF <ralfschiff...@tropo.com> wrote:
> fairly new to git. Today I did a "git add somefile" and then decided
> I wanted to unstage it. I did then a "git rm -f somefile". There was
> no git command in between. Particularly no commit.
> git wiped the file from disk. I worked very hard on that file
> (several days( and I really hope this can be recovered. I could not
> find a solution on the web.
> For completeness I did a git reset HEAD somefile because that's what
> I found on the web, but it didn't recover the file.
> Is there a way to recver somefile?
Oh, and while we're at it.
The correct way to unstage the currently staged file's changes is to do
git reset HEAD that_file
which reverts the state of the file in the index (the staging area)
to whatever is recorded in the tip commit of the current branch -- the
state the index is initially based on.
There's also the "--cached" option of the `git rm` command which
removes the file from the index but does not remove it from the work
tree. It's surely less destructive: once it completes, you still have
your file in the work tree -- being untracked by Git, but note that
this command is different to `git reset`: `git rm --cached` means "I
want this file to be not be not present in the next commit, at all",
while `git reset HEAD` merely removes the changes to the file you
intended to commit but then changed your mind.
While this topic is still warm in your mind, I'd heartily recommend
You received this message because you are subscribed to the Google Groups "Git
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email
For more options, visit https://groups.google.com/d/optout.