0

So I have a commit to my local branch that has yet to be pushed to my remote. I worked a little after my local commit and decided to go back to what I had committed. I selected the Discard All Changes . . . under Source Control but it seemed to go back farther then I wanted. I can see the commits under my History . . . but when I select Pull . . . all I get is options for my remote branch (which still shows a branch that I terminated, so helping me refresh that would be great too but the other thing is more important right now).

Any and all suggestions are greatly appreciated.

Solution: So what I ended up doing was using git log to find the commit that I wanted. I copied the commit number. Then git reset --hard *commit #*. The files were in my Finder window but no in my Xcode project, so I went to Files->Add Files to "projectName" and added the files. After I assured myself that everything was fixed I committed my build using git push --force.

Hope that is helpful to someone, feel free to comment if you have any questions on my solution.

CGTheLegend
  • 734
  • 1
  • 7
  • 19

1 Answers1

1

CGTheLedgend,

So when you git pull you are actually pulling source code from your remote repository into your local one. Instead what you want to do is a git log which will show all your commits in the following format:

 commit f5c5cac0033439c17ebf905d4391dc0705dbd5f1
 Author: CGTheLegened  
 Date:   Fri Sep 6 14:36:59 2010 -0500

     Added and modified the files.

 commit c14809fafb08b9e96ff2879999ba8c807d10fb07
 Author: CGTheLegened 
 Date:   Tue Sep 4 08:59:32 2010 -0500

    Just simple test for core.editor.

 ... etc ...

From here, you want to use the git reset command to go to a specific commit. If you do:

  git reset --hard c14809fa

To make your local code and local history be just like it was at that commit.

Please let me know if you have any questions!

Devarsh Desai
  • 5,984
  • 3
  • 19
  • 21
  • So I used the command that you suggested. It says that my HEAD is no pointing to the commit that I want but the change is not showing up in XCode. I already tried quitting XCode and starting up again. – CGTheLegend Sep 15 '14 at 15:39
  • 1
    Hey CGTheLedgend, ahh yes; I've come across the situation you're in right now; you should read through this answer first (http://stackoverflow.com/questions/5772192/git-how-can-i-reconcile-detached-head-with-master-origin) to give you a sense of where you are right now; the steps listed there should work for you; if they don't please reach out and ask me any questions! Thank you for your time! – Devarsh Desai Sep 15 '14 at 16:42