I'm definitely overcomplicating this, but I am wondering how to "unstage" the changes that were made to a few files inadvertently in a commit in a pull request. Without making a mess in Git.
Basically there were some files in a /dist
folder that were slightly changed on accident after the application compiled.
The catch is I am trying to avoid making extra commits or having to squash my commits, if possible. Can this be done with git commit --amend
?
If you have changed the files in PR, and have them currently staged, and don't want to further alter the files in /dist
on remote, simply unstage everything on PR ( git reset
), then re-stage all but files in /dist
(on PR), and then wipe the local changes to the files in /dist
:
git clean -df
git checkout -- .
This won't touch the staged/committed files.
But somehow I have a feeling what you're trying to do is not this uncomplicated.. If you want to revert the files in remote /dist
, then it's best to do another commit, perhaps with revert
(or if you can afford to rewrite the remote repo history, ie you know for sure others haven't pulled a copy, or can/want to communicate it to the rest of the team, then check out the history-altering approach to undoing the change in my recent other answer ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.