git reset
See original GitHub issueI’m trying to reset a branch to a particular commit (i.e. git checkout <branch> && git reset [--soft] <commit>
) but there doesn’t seem to be a reset command.
@wmhilton do you have plans to implement this in the near future? I don’t want to swamp you with more requests 😅 Seems like an easy thing to do manually by editing stuff in .git/
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (6 by maintainers)
Top Results From Across the Web
git-reset Documentation - Git
You can use git reset to rewind history without changing the contents of your local files, and then successively use git add -p...
Read more >Git Reset - W3Schools
Git Reset. reset is the command we use when we want to move the repository back to a previous commit , discarding any...
Read more >How do I use 'git reset --hard HEAD' to revert to a previous ...
First, it's always worth noting that git reset --hard is a potentially dangerous command, since it throws away all your uncommitted changes.
Read more >Git Reset | The Git Reset Command Explained
The main result of using the git reset command is to repoint the branch label of your currently checked-out branch to a different...
Read more >A git reset hard example: An easy way to undo local commits ...
Unlike the git cherry-pick and the git revert command, the git reset hard command does not create a new commit but actually rolls...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Well, IIRC
--hard
has two additional effects: clearing the index and updating the working tree (checking out the branch). In theory you could do those two manually with:You also need to find out what commit HEAD~1 points to. I’m not sure if you could just pass
"HEAD~1"
and have the library resolve it for you, that would be a question for @wmhiltonNOTE: I haven’t tested this myself so use carefully
it works but you made typo in path it should be
'/.git/index'
I use this code to reset toHEAD~<NUM>
: