-1

So, I kind of messed up and went and deleted all my files on C9. I haven't saved anything yet, so I'd like to pull my last commit into my C9. I read somethings that said I should download the zip file of the commit, but I don't really know what to do with that. If anyone could help me I would really appreciate it!

If you guys need any more info, I want to pull from my last commit because I deleted all my branches except my master branch and all the hidden files that I might need later. I couldn't really find anything about pulling into C9 from Github so I thought this would be a good question to ask you guys.

Jin Tak
  • 11
  • 1
  • Tough to tell where you are with the information you've provided (were you working in a Git repository? Did you clone one? Have you made any commits? etc) but I'd suggest using the revision history feature of Cloud9. See https://community.c9.io/t/how-do-i-recover-a-deleted-file/17 – Brady Dowling Jan 24 '17 at 23:18
  • @BradyDowling I do have commits (and why I want to fetch/pull from it). I haven't cloned anything (do I need to?), I put `rm -rf .git` without knowing what it was, could I recover my files from that? My C9 is already linked with my Github. I don't want to clone the IDE that I'm working on right now as I basically screwed everything up, but I want to fetch/pull from my last commit because I committed everything before screwing everything up. – Jin Tak Jan 25 '17 at 22:18
  • Did you push anything to Github? If not, you deleted all your commits. You will now have to depend on the link I mentioned above to recover any files. – Brady Dowling Jan 25 '17 at 23:10
  • [This](https://github.com/jinntakk/upskill_saas_tutorial) is my Github page. I have 36 commits on it. And yes I pushed everything I was working on until I deleted everything. And the reason why I want to pull my last commit so I can start again from that point. – Jin Tak Jan 25 '17 at 23:34

1 Answers1

0

you can delete all the files that you do not need then run the following

cd ~/workspace # make sure you are in the right folder
git init .     # create new git repo instead of the one you've deleted
# now add your github repository as origin
git remote add origin git@github.com:jinntakk/upskill_saas_tutorial.git -f
git remote set-head origin -a

git fetch                    # fetch your commits from github
git reset origin/HEAD --hard # reset working tree to the remote
a user
  • 23,300
  • 6
  • 58
  • 90
  • I did everything but when I run `git branch` on console it only shows master. Did I do something wrong? – Jin Tak Jan 26 '17 at 19:43
  • Also, when I did `git remote add origin git@github.com:jinntakk/upskill_saas_tutorial.git -f` it seemed to add my other branches. So I think I did something right. Anyways thanks so much for the help. I feel like I'm one step closer to bringing everything back. – Jin Tak Jan 26 '17 at 19:45
  • `git branch` shows only local branches, use `git branch -a` to see remotes – a user Jan 26 '17 at 21:52