Shobhit Kumar
Shobhit Kumar

Reputation: 656

how to redo merge conflict resolution for cherrypick without losing the changes(after the commit)?

Here are the steps that have led to the issue:

  1. Cherry picked a commit
  2. Resolved the merge conflict
  3. git add the files that were resolved
  4. git commit
  5. Then i realised, there are compilation errors. i have fixed them.

And now, how do i add these changes to the previous commit without having to resolve the merge conflict. I am hesitant in trying to git reset HEAD~ so that i don't lose the changes. it has been a long resolution.

will a git reset HEAD~ work?

Upvotes: 0

Views: 323

Answers (1)

Chris Maes
Chris Maes

Reputation: 37722

git add <your-files>
git commit --amend --no-edit

or in a single command:

git commit -a --amend --no-edit

the flags:

  • -a : commit all unstaged and staged changes (no need for git add)
  • --amend: put the changes in the previous commit
  • --no-edit: and keep the commit message as it was

will a git reset HEAD~ work?

Yes, that is another but longer option, but gives the same result:

git reset HEAD~ # undo last commit
git add <your-files>
git commit -m "message"

Upvotes: 4

Related Questions