Re: Request: `git restore $commit $file` shouldn’t override uncommited changes
- From
Robin Moussu <moussu.robin@pm.me>
- Date
- Apr 28, 2021, 08:35 UTC
- Message-ID
- <I_ZK84DfFkUoO9FcqjidSjmsvktNt-k4tPiAGNIP5ztKjk0RQCfFmyRrRHaB414UaWsJO7kWPBcgHlRqAecH7r9mAj0TLm5k6T5_YzmiZ4c=@pm.me>
- In-Reply-To
- <20210427192906.7obdkopxwajqnv53@gmail.com>
I effectively did a typo, I meant `git checkout $commit $file` or `git restore -s $commit $file`. I forgot the --source in the `git restore` command.
Show 9 quoted lines
> Is your question that you expect a command like > > git restore --source=some-commit some-file > > to error if you have uncommitted changes (to "some-file")? > And instead you would run > > git restore some-file > git restore --source=some-commit some-file
Exactly. If `--source $commit` isn’t specified, erasing uncommitted changes is what I expect. I scream-up, and want to start from a fresh state.
On the contrary, if `--source $commit` is specified, I would like to get an error if $file has uncommitted changes. The reason I want to error when `--source $commit` is specified is because I most probably didn’t screw-up, but just forgot that I modified the file before copying its content from another revision.
Robin.
---
Should I wrap my text in 80 column? I’m not familiar with plain-text netiquette.