-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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 new rule, how to discard specific unstaged changes #103
Conversation
If I was required to open an issue first I can do that, please let me know. I am very new to contributing to non-work projects. Thanks |
You're good, @codeofcarson, this was the right way to do this! Thank you. As it happened, I ran across this issue today, and didn't think of resetting sections this way. Good thinking! Might be good to mention that what you're doing with
This will delete all of the snippets in the latest stash, while keeping old stashes and not effecting lines you don't add to the stash. Perhaps you should mention this strategy, too? And add a How does that sound? |
I see this is your first PR - Well done! ⭐️ You're awesome. In case you don't know, to add the changes I suggested, just add another commit on top of this, or amend your commit and force push to this branch. |
Thanks! I was slightly nervous about it but I'm glad I got it mostly correct. I have made the changes you have described and force pushed an amended version of the commit. This should incorporate all of your suggestions which, in my opinion, improve the quality of my commit. |
$ git stash -p | ||
# Select all of the snippets you don't want to save | ||
git stash drop | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs closing ```.
|
||
When you want to get rid of some, but not all changes in your working copy | ||
|
||
First strategy, stash all good changes, reset working copy, reapply good changes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a period at the end :)
<a href="i-want-to-discard-specific-unstaged-changes"></a> | ||
### I want to discard specific unstaged changes | ||
|
||
When you want to get rid of some, but not all changes in your working copy |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a period at the end.
$ git stash pop | ||
``` | ||
|
||
Alternate Strategy, stash undesired changes, drop stash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uncapitalize 'Strategy'
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good! Almost done; just some style changes now.
Fixed. |
Awesome! Thank you! <3 🌴 |
Happy to help. Great experience, would PR again 10/10. |
I ran into a problem where I wanted to get rid of some hunks in my changes but wasn't ready to commit, and I wasn't having an easy time doing it because some of the hunks were in files where I had made changes I wanted to keep.
I could discard all changes to a file with git checkout but needed a way to sift out the good ones and keep them in my working copy.
Stash ended up being the best tool since you can stash -p and stash only specific hunks.