Xcode 4 restore file from earlier commit
I have my project on a git repository and so far I'm not finding it terribly us开发者_Python百科eful. I've used git before and think it's great, but this time I'm using a local repo. I figured that there would be some way of restoring files to a previous commit, or even the entire project but I can't find this option?
Is there a way of doing this? Or do I have to create a branch in advance. Because that seems like you have to know in advance that something us going to go wrong.
Also I can't find an option to discard all local changes across my project, effectively reverting to my last commit.
I can't find an option to discard all local changes across my project, effectively reverting to my last commit
git reset --hard HEAD
See git reset
: that will reset the working tree and the index to what HEAD
is currently referring to.
See also the Git book "Undoing in Git - Reset, Checkout and Revert"
For the first part, see git checkout
, but beware of detached HEAD.
A bit late to this party.
If you can't hack the command line option (it is the best option IMHO) you could try using github:mac to revert / commit / stage code in conjunction with xcode.
It is a very nice and easy to use UI on top of git and it's FREE!!
Don't worry you're not required to push your repo's to github as it will naturally manage local repositories without any fuss.
I regularly use it to rollback projects. Care must be taken when doing this however.
Try not to place 'project.xcworkspace' under revision control. Shutdown Xcode before reverting & discard or stash uncommitted changes.
I'm currently in the same boat. It looks like Xcode4 wants us to use the snapshot feature. That has the restore option we want, provided you hit the Create Snapshot when you did your commit. It's conveniently located right under Version Control in the File drop down. The Create Snapshot uses the control + command + s shortcut, which is pretty handy seeing as how I hit command + s for the save hot key often. Or even better yet. Automatically
精彩评论