There has been some question on reverting back to a commit in git but I wanted to make sure. This SO page is one that helps the most: How to revert Git repository to a previous commit?
I have a previous commit, say 1.0 for a customer and it is complete. I commit (not sure if I push) and then create a new branch to work on the next version. Now, for some reason, the binary for 1.0 is "corrupted" and I need to go back but also keep the current modifications.
git log reveals this:
commit be01d2a99ec35bbfcdbca47d5570acef8c69b275
Author: Yko <[email protected]>
Date: Mon Apr 25 10:25:35 2011 -0400
So, the steps I need to take is this?
1. git add .
2. git commit "good stopping point for v1.1"
3. git checkout be01...
I am assuming step #3 modifies all the source code? This is an XCode project (iPhone app) so I just have to reload the project file, build, and have the new binary .app?
Then, goes back to the latest version 1.1 with
git checkout "latest commit #"?
Thanks,
I'm new and don't want to lose any work. Appreciate the help!!!
EDIT: Based on a few answers, I want to clarify. 1. I do not want to merge any branches. I want to go back to version 1.0 and rebuild the source to create a new binary then hop back to where I was. Suppose verision 1.0 have apples to be $1.00 and version 1.10 have apples to be $1.10. I want to go back to version 1.0, rebuild the source code where apples are $1.00, give the binary to customer x. Then, hop back to version 1.10, keep working on it.
Thanks again!!!
An administrator can roll back the code repository to a previous commit -- that point-in-time copy -- in several ways, depending on the end goal. One approach is the git reset command. Before using this command, you must understand what git reset does.
You could do it like this:
git tag 1.0
git add .
git commit -m "good stopping point for v1.1"
git tag 1.1
git checkout 1.0
.. do your build stuff/whatever
git checkout 1.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With