Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

grandM

macrumors 68000
Original poster
Oct 14, 2013
1,539
304
Hi everybody

I'm cursing at Xcode. Xcode used to have a snapshot function. Using this function once could revert to previous states. Then Xcode changed to git. So I'm committing my changes and pushing them.

What is not clear however is how I can revert my entire project to a previous commit for instance? Can someone help me out?

Tx!

ps: I would also like to know if there is an easy way to copy a project. This new project should be totally independent from the original one.
 
Last edited:
If you're using one of the online git servers they usually have a Revert Button that will revert a commit. If you're working on branches like you should there will be a single merge commit that merges your feature branch to master so reverting that single commit will revert all the commits on that branch.

You can also use the git revert or git reset commands but read up on them to see how to use them.

Here's a page that explains this:

https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting/commit-level-operations

Remember that until you push your changes they private. So I would clone a new workspace. Try the git operations to revert to the commit you want. Then only push to origin when things in your workspace are the way you want. You can simply delete the workspace and start over if it's not going well.
 
If you're using one of the online git servers they usually have a Revert Button that will revert a commit. If you're working on branches like you should there will be a single merge commit that merges your feature branch to master so reverting that single commit will revert all the commits on that branch.

You can also use the git revert or git reset commands but read up on them to see how to use them.

Here's a page that explains this:

https://www.atlassian.com/git/tutorials/resetting-checking-out-and-reverting/commit-level-operations

Remember that until you push your changes they private. So I would clone a new workspace. Try the git operations to revert to the commit you want. Then only push to origin when things in your workspace are the way you want. You can simply delete the workspace and start over if it's not going well.
I partly get it but I need to have different versions illustrating the making of. People are given commit 2 and must code their way to commit 3. So I want to have a copy of the entire project on commit 1, 2, etc.

You refer to the git server to revert a commit. So Xcode cannot revert all changes at once? Won′t a clone resolve in working on the original version?
 
Last edited:
You can use git checkout to change your workspace to a particular commit or tag and you could zip it up in that state.
git archive will zip your repo at a specific commit but the unzipped archive won't be a git archive. Like this:

git archive -o version1.zip HEAD
 
You can use git checkout to change your workspace to a particular commit or tag and you could zip it up in that state.
git archive will zip your repo at a specific commit but the unzipped archive won't be a git archive. Like this:

git archive -o version1.zip HEAD
I'm a bit lost. I made a Xcode example project and made two commits which I pushed to a git server. Under the tab Source Control I see the option Checkout... The option is greyed out though? Hold on, now it's active again but I'm crashing as Xcode indicates it can't find the branch. It also gives the following error code "Reference 'refs/heads/master' not found (-9)". Hmm I'll have to run some tests, not sure why it doesn't find it as I just selected an url indicated by Xcode itself, so it ought to find it.
 
Last edited:
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.