I have several commits already and I need to undo the latest one but to have changes I made in it in place. Please advice how to do that. Thank you.
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Note that you should only rewind HEAD if it’s not pushed yet.
edit In response to your comment on the original question:
If you only want to edit the most recent commit, Git has a neat feature
commit --amend. Simply usegit add/git rm/git checkoutuntil your index is in the state you want it to be (new changes added, some changes thrown away, files removed, …). Then usegit commit --amend, it will pop up vi (or whatever you have configured incore.editor) with your last commit’s commit message for you to edit.Note, that when I say ›edit the most recent commit‹, Git actually creates a new commit. So don’t do it, when the commit was already pulled from other people (i.e. pushed to your public repository)