Hacker News new | past | comments | ask | show | jobs | submit login

  It's surprisingly hard to unstage a file.
Is there a case when it's not a simple git reset my-file away?



Yes there is. When you have a new repository without any commits, there is no HEAD, so you can't unstage by resetting.

    mkdir try
    cd try
    git init
    touch file
    git add file
    git status
Still, the git status command shows you what you need to do to unstage.


Indeed no. That's exactly what git reset does: "copy entries from <commit> to the index". I got that from the unusably bad man page. It was the first sentence.


My question was a rhetorical one :)


I know. But you were needlessly agreeable. I thought some salt needed to be rubbed into the GP post.


And in every git status message.


I forget my exact edge case. Something to do with wanting to unstage a folder, or unstaging a folder while wanting to preserve work in some of the files.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: