-
Notifications
You must be signed in to change notification settings - Fork 41
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a git reset --hard {commit}
equivalent
#60
Comments
Will this let me peel a commit off so I can reset it? Edit: I totally thought this was a PR 😂 So yes, I agree. Being able to do a soft reset would be very helpful. |
FYI a slightly less magic / undocumented way - of resetting your branch head to a commit of your choice such as HEAD^ is as follows:
Of course we can make a reset command one day - seems like it has never quite been a priority - but at least this workaround is something I'd be okay with putting in public documentation. |
@rcoup I want Rob to okay this plan before I (or anyone) does any work on it - The way that However, seems like a We could also add support for --hard and --soft, maybe, except - maybe that's adding too many confusing things again. |
I find sno's reset command a bit confusing because it isn't the same as git's reset command at all:
IMO we shouldn't add a flag to the existing
|
So maybe we kinda follow that approach (except dropping the overlap between reset & restore?)
And continue to prefer |
+1 to not using checkout for this stuff - git checkout does too many things: - do nothing / populate the workdir if not yet populated (git checkout) (Some versions of this command are safe and warn me if they would overwrite any local changes - But that's an aside. The plan above is good as far as it goes:
However, in Sno, so far we don't ever allow the branch tip to be manipulated without also resetting the working copy, unless the new branch tip is basically the same as the old one. Here we differ from git. We could change this behaviour to be more like git if it seems important - we can't be exactly like git since, for instance, a newly added file can almost always be kept when changing branches in git, but a newly inserted feature maybe can't be kept when changing branch in sno - specifically, it can't be kept if it doesn't match the target branch schema. Assuming we don't change this behavior, this would mean that most resets would also be restores as well. Or to put it differently, most resets would be hard resets. Here is the full list of possibilities, with behaviour consistent with existing Sno commands (eg switch / checkout):
What do you think - is this good enough? Or do we need to add functionality more in line with what git can do - switch / reset operations that change some parts of the working copy, while keeping edits to other parts of the working copy? *If HEAD is detached and there is no branch tip, reset affects HEAD directly. In this case reset works the same as checkout. |
What you've proposed sounds good to me 👍 |
At present
sno reset
exists, but it actually does something totally unrelated togit reset
: it throws away uncommited changes in your working tree. That's the equivalent ofgit checkout .
git reset actually doesn't touch your working tree; it modifies the repository head and possibly the index. So it's a totally different command.
In testing sno, I find myself needing a more gittish reset command so I can undo a commit easily. At present I'm using
BRANCH=$(git symbolic-ref --short HEAD) ; sno checkout HEAD^ ; git branch -f $BRANCH HEAD ; sno checkout $BRANCH
, but obviously that's cumbersome.I assume a reset command would be useful generally, but at least for testing sno it's sorely missed.
The text was updated successfully, but these errors were encountered: