0

Given a scenario where commit 1 installs a whole new functionality therefore it adds, deletes and changes a few functions. Afterwards a few commits are performed that only fix minor problems found in the meantime.
Is it possible to skip over commit 1 but at the same time get all commits performed after it ending up with a solution containing all fixes but without the new functionality ?
I'm afraid the solution may have some conflicts or whatever they call it since the fixes were implemented over the code associated with the aforesaid functionality.

utxeee
  • 953
  • 1
  • 12
  • 24

2 Answers2

2

git rebase -i COMMIT1^ should let you remove that commit. You're right that you may need to resolve some conflicts.

Carl Norum
  • 219,201
  • 40
  • 422
  • 469
  • Any way to automate the conflict resolving process ? – utxeee Jan 30 '13 at 23:22
  • Well, it will resolve simple ones on its own, and difficult ones have to be dealt with by a human, pretty much by definition. I'm not sure I'm following what you're asking, exactly. – Carl Norum Jan 30 '13 at 23:23
  • In case of conflict we could provide some rules in order to get GIT end up with a solution without human intervention. – utxeee Jan 30 '13 at 23:26
  • git provides several merging strategies. Maybe one of them will work for you. `git help rebase` should get you started. – Carl Norum Jan 30 '13 at 23:27
  • 1
    If human resolution seems troubling to you, you are probably not using a proper mergetool – what os are you using? – Chronial Jan 31 '13 at 01:11
  • Is REBASE able to solve conflicts when changes are made in the same file but at distinct lines? – utxeee Feb 06 '13 at 11:08
  • Usually, yes. That shouldn't be a problem, since those aren't conflicts. – Carl Norum Feb 06 '13 at 15:25
1

As Carl Norum suggested, you should probably use git rebase (but only after you have read what the implications are).

If you can not rewrite the history or the amount of conflict resolution gets too much because you had many commits after that, there’s an alternative: You can create a new commit that undoes commit the changes of commit 1 by running:

git revert COMMIT1

If there are conflicts, you will also have to run

git mergetool -y
git commit
Community
  • 1
  • 1
Chronial
  • 66,706
  • 14
  • 93
  • 99
  • Is mergetool an automatic merging process or once again if some "hard" conflict arises human intervention will be needed ? – utxeee Jan 31 '13 at 12:40
  • Mergetool is a tool for manual merging – but if you use a proper one, that’s usually a very quick and easy process. – Chronial Jan 31 '13 at 13:00