2

I have a local git repository for an Xcode project. How do I checkout (from Terminal) a specific revision of the project to a different folder?

Thanks.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Andrei Marincas
  • 446
  • 5
  • 13
  • 1
    Do you only have a local version? No remote repositories? Define `specific version`. A branch? – reto Jul 14 '14 at 08:39
  • possible duplicate of [How to do a "git export" (like "svn export")?](http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export) – Sascha Wolf Jul 14 '14 at 08:53
  • @reto By 'specific revision' I mean a revision other than HEAD. Maybe these are just SVN terms? If I go to Xcode I can see the project's history of commits, so I would like to checkout somewhere in the history, not only at the latest commit. – Andrei Marincas Jul 14 '14 at 12:57
  • @Zeeker This doesn't help me [How to do a "git export" (like "svn export")?](http://stackoverflow.com/questions/160608/how-to-do-a-git-export-like-svn-export) it's more about archiving/exporting, I actually want to be able to commit after checkout, so that I can make the revision to be the most recent one. – Andrei Marincas Jul 14 '14 at 13:03

1 Answers1

5

You can clone a local repo into another folder:

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Cloning without the '-b' option works for taking the most recent version of the project. But what is the difference between these two commands? They both require a remote branch. I only have one branch, and I would like to checkout at some point in the history of commits. – Andrei Marincas Jul 14 '14 at 13:15
  • @AndreiMarincas no: one requires a remote branch, the other a tag. but you can remplace 'my-branch' or aTag by any SHA1 you want, allowing you to clone at any point in the history of the rpeo. – VonC Jul 14 '14 at 13:26
  • It works but I have to tag the commits first, this also helped [Git tag older commit?](http://stackoverflow.com/questions/4404172/git-tag-older-commit). So using '-b' option is a must, but one last thing: what is the difference between '-b' and '--branch'? Are they the same with 'clone'? Do they create a new branch with 'checkout'? – Andrei Marincas Jul 15 '14 at 07:44
  • @AndreiMarincas yes, `-b` and `--branch` are the same. For tag, the result will be a repo checked out at the right tag, but in a detached HEAD mode. – VonC Jul 15 '14 at 07:45