سؤال

I am backtracking through my history to find what exactly broke iOS5.1 for my app. I've traced it to a single commit, however the commit has many files.

I would like to git checkout [commit before iOS5 break] and have all of the changes from the commit that broke iOS5 (ie. the next commit) merged into the commit before it without having the changes committed. That way I can simply revert each file until I find the one with the changes that broke iOS 5.

Any idea on how to take the changes from the commit and put them on my current branch without having them committed yet?

Thanks.

هل كانت مفيدة؟

المحلول

You must create a branch first:

 git checkout -b fix bcd7c93
 git merge -n 8b53674 # merge without auto-commit

Your solution creates:

  • a detached head: you wouldn't be able to merge at all, since your next commits wouldn't be referenced by any branch HEAD (hence the "detached" part)
  • a duplicate commit: you wouldn't be able to easily merge back your 'fix' branch to master (or your current branch from which you found the defective commit)

The idea is to be able to fix the bug (one or two files modified) and merge it back on the main branch without repeating all the other files part of the commit you have found being problematic.

نصائح أخرى

Sorry to answer my own question, but it turns out that cherry-pick has this option:

git checkout -f bcd7c93
git cherry-pick -n 8b53674
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top