1

I am trying to figure out how to open an old version of my Xcode project that is stored in GitLab. Usually, I use Xcode to push updates to Gitlab and on the occasions, I've had to get my project from GitLab, I simply click the "Open in Xcode" button on GitLab, which brings my project up.

The problem that I'm having now is that I've accidentally introduced a bug into the project that crashes the app and I can't figure out how to crush this bug. The last couple of updates to GitLab contain this bug so I need to revert to a copy a bit in the past. When I click on this update, there is no open in Xcode button, and I'm unsure about how to open this previous version.

I'm hoping that there is a straightforward solution to getting this old version of this file up. I'm just getting started using git, and I'm hoping someone on here can provide some insight.

Can someone please point me in the right direction on the easiest way to revert to an old project update on GitLab?

Ryan
  • 630
  • 8
  • 20
  • The needed commands can be found by clicking history and then browse files in GitLab. – Ryan Apr 20 '20 at 23:55

1 Answers1

1

It seems easier to:

  • close XCode
  • cd /path/to/local/clone/of/GitLab/repo
  • switch to the command line and type git switch <old SHA1> in order to update the working tree with the files content of that past SHA1
  • open XCode back up.

(Note: git switch is better than the old legacy git checkout command)

If you want to commit some fixes, your git switch command will be:

git switch -c fix <old SHA1>

That will start a fix branch starting from <old SHA1>.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I find a command whose entry in the man pages says "THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE" rather scary. – matt Apr 16 '20 at 16:29
  • @matt That was for Git 2.23, August 2019. It shows no sign of going away, and 2.25.1(https://github.com/git/git/commit/ad9c8954638759658453588075b0e18af914f566) still promotes it (Feb. 2020). I don't have any inside knowledge, but I would be surprised if the command was completely removed. It works well, and just make sense (example: "no more unwanted detached HEAD: https://stackoverflow.com/a/3965714/6309) – VonC Apr 16 '20 at 16:59
  • Agreed, obviously I want to see the heavily overloaded `checkout` broken up. – matt Apr 16 '20 at 17:15