Reputation: 8597
Is there a way to keep all my changes now, and still reverse back my app to a certain commit and start going through all other commits to see which one caused an issue in my app?
I did a lot of changes, and it would take me a long time to check everything, so I want to get my previous commits and when I find the issue, I'll revert back to most recent commit and then just apply the necessary changes.
There's this answer here: git revert back to certain commit but I still want to keep all my recent changes, can someone walk me through the thought process?
I'm thinking if I commit my most recent changes now, its in bitbucket, then use the method: git reset --hard {commit numbers}
and just keep going through my list of commits, and when I find the issue, git reset --hard {most recent commit}
this will bring me back to most recent state?
Upvotes: 7
Views: 1355
Reputation: 3145
There is a command for what you want to do and it is called git bisect
which uses binary search to find the commit that has not been working. The process is
git bisect start
git bisect bad
git bisect <your last good commit here>
Here is a fairly easy to read guide.
This will permit you to find which commit caused the issue.
Upvotes: 4
Reputation: 18504
Commit all uncommited changes, clean the tree of untracked files, then you can just do
git checkout <some_commit_sha>
to go to that specific commit, and then git checkout master
(or other branch) to get back.
Just do not commit anything, while being in 'detached' state, if you must - you can start a branch there and proceed as usual
Upvotes: 5