step 1: "hide" the modifications you haven’t committed yet.
git stash save <descrição>
step 2: reset the last commit of the branch taking its modifications to staging area.
git reset HEAD~
here (step 2) if you want, you can commit the modifications again or remove them at once with: git checkout -- < file>
step 3 (optional): recover the "hidden" modifications in step 1 and apply again under the code.
git stash list
list all stashs made
git stash apply stash@{numero-da-stash}
apply the selected stash under the code
when applying stash, conflicts may occur that must be resolved
WARNING
After you make the changes you want and make a next commit, when you try to push again, you will receive an error because the local tree will be different from the remote tree since you pushed and then reset the commit locally. To proceed with the push you can use:
git push --force
before giving this command make sure that your branch is organized with the commits you want, because this branch will replace the remote
git reset --hard, maybe?
– epx
You want to discard the current changes and leave it the same in the last commit you pushed?
– Wilker
exact! I want to pick up where I left off in the last commit. what I did after was wrong and I can’t find the error.
– Rodrigo Emanuel
Right! If any answer has solved your problem consider ticking as accepted.
– Wilker