{"thread":{"id":"30455","subject":"Broken Repo","startedAt":"2012-05-07T03:36:53Z","lastAt":"2012-05-07T18:12:40Z","messageCount":4,"participants":["Joe Zim","Marcus Karlsson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"190962","messageId":"4FA74355.3020704@joezimjs.com","threadId":"30455","inReplyTo":null,"subject":"Broken Repo","fromName":"Joe Zim","fromEmail":"contact@joezimjs.com","sentAt":"2012-05-07T03:36:53Z","receivedAt":"2012-05-07T03:36:53Z","isPatch":false,"sender":{"key":"contact@joezimjs.com","avatar":null},"body":"Hi, I'm new here. I'm using Github right now. I have a repository there \nand a local copy on my Windows 7 PC. I made a change, committed it, then \nattempted to push it. I got a strange error that I can't remember. \nAnyway, after several attempts I decided to just delete the local \nrepository, restore it from github and try again later. I realize now \nthat there were other ways this should have been handled, but right now \nit doesn't matter. I can't figure out how to restore a copy from Github \nand make this renewed repo the master branch. Can anyone give me a \ndetailed, step by step answer please?\n\nThanks,\nJoseph Zimmerman\n"},{"id":"190967","messageId":"20120507073713.GA863@hatchepsut.acc.umu.se","threadId":"30455","inReplyTo":"4FA74355.3020704@joezimjs.com","subject":"Re: Broken Repo","fromName":"Marcus Karlsson","fromEmail":"mk@acc.umu.se","sentAt":"2012-05-07T07:39:58Z","receivedAt":"2012-05-07T07:39:58Z","isPatch":false,"sender":{"key":"mk@acc.umu.se","avatar":null},"body":"On Sun, May 06, 2012 at 10:36:53PM -0500, Joe Zim wrote:\n> Hi, I'm new here. I'm using Github right now. I have a repository\n> there and a local copy on my Windows 7 PC. I made a change,\n> committed it, then attempted to push it. I got a strange error that\n> I can't remember. Anyway, after several attempts I decided to just\n> delete the local repository, restore it from github and try again\n> later. I realize now that there were other ways this should have\n> been handled, but right now it doesn't matter. I can't figure out\n> how to restore a copy from Github and make this renewed repo the\n> master branch. Can anyone give me a detailed, step by step answer\n> please?\n> \n> Thanks,\n> Joseph Zimmerman\n\nYou deleted the local repository and want to clone it again from\nGitHub right?\n\nYou can run 'git clone git@github.com:username/reponame.git' and\nthat should give you a new local repository cloned after the repository\non GitHub. Just replace username and reponame with the appropriate names\nfirst and you should be up and running.\n\n\tMarcus\n"},{"id":"190968","messageId":"20120507074917.GE18812@sigill.intra.peff.net","threadId":"30455","inReplyTo":"4FA74355.3020704@joezimjs.com","subject":"Re: Broken Repo","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2012-05-07T07:49:17Z","receivedAt":"2012-05-07T07:49:17Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, May 06, 2012 at 10:36:53PM -0500, Joe Zim wrote:\n\n> Hi, I'm new here. I'm using Github right now. I have a repository\n> there and a local copy on my Windows 7 PC. I made a change, committed\n> it, then attempted to push it. I got a strange error that I can't\n> remember. Anyway, after several attempts I decided to just delete the\n> local repository, restore it from github and try again later. I\n> realize now that there were other ways this should have been handled,\n> but right now it doesn't matter. I can't figure out how to restore a\n> copy from Github and make this renewed repo the master branch. Can\n> anyone give me a detailed, step by step answer please?\n\nI don't quite understand your question. You deleted the original\nrepository, which I assume means you removed the whole working tree. So\ncan you not \"git clone\" the original repository again and redo your\nwork?\n\nOr did you remove only the \".git\" directory, leaving your modified\nworking tree in place? If that is the case, you probably want:\n\n  # turn your directory back into a git repository\n  cd $your_project\n  git init\n\n  # fetch the existing work again\n  git remote add origin $your_remote_url\n  git fetch\n\n  # now tell git that we are basing our branch on the upstream master.\n  # We must make sure not to use \"--hard\" here, because that would\n  # overwrite the working tree.\n  git reset origin/master\n\nAt this point you should be able to use \"git status\" to see your\nchanges, and commit as normal. You might also want to run:\n\n  git branch --set-upstream master origin/master\n\nto make \"git pull\" work without any arguments. This setup is done\nautomatically by \"git clone\", but not by the manual init+fetch we did\nabove.\n\n-Peff\n"},{"id":"191020","messageId":"4FA81098.3000208@joezimjs.com","threadId":"30455","inReplyTo":"20120507074917.GE18812@sigill.intra.peff.net","subject":"Re: Broken Repo","fromName":"Joe Zim","fromEmail":"contact@joezimjs.com","sentAt":"2012-05-07T18:12:40Z","receivedAt":"2012-05-07T18:12:40Z","isPatch":false,"sender":{"key":"contact@joezimjs.com","avatar":null},"body":"Thanks for the reply guys. It's fixed now.\n\nOn 5/7/2012 2:49 AM, Jeff King wrote:\n> On Sun, May 06, 2012 at 10:36:53PM -0500, Joe Zim wrote:\n>\n>> Hi, I'm new here. I'm using Github right now. I have a repository\n>> there and a local copy on my Windows 7 PC. I made a change, committed\n>> it, then attempted to push it. I got a strange error that I can't\n>> remember. Anyway, after several attempts I decided to just delete the\n>> local repository, restore it from github and try again later. I\n>> realize now that there were other ways this should have been handled,\n>> but right now it doesn't matter. I can't figure out how to restore a\n>> copy from Github and make this renewed repo the master branch. Can\n>> anyone give me a detailed, step by step answer please?\n> I don't quite understand your question. You deleted the original\n> repository, which I assume means you removed the whole working tree. So\n> can you not \"git clone\" the original repository again and redo your\n> work?\n>\n> Or did you remove only the \".git\" directory, leaving your modified\n> working tree in place? If that is the case, you probably want:\n>\n>    # turn your directory back into a git repository\n>    cd $your_project\n>    git init\n>\n>    # fetch the existing work again\n>    git remote add origin $your_remote_url\n>    git fetch\n>\n>    # now tell git that we are basing our branch on the upstream master.\n>    # We must make sure not to use \"--hard\" here, because that would\n>    # overwrite the working tree.\n>    git reset origin/master\n>\n> At this point you should be able to use \"git status\" to see your\n> changes, and commit as normal. You might also want to run:\n>\n>    git branch --set-upstream master origin/master\n>\n> to make \"git pull\" work without any arguments. This setup is done\n> automatically by \"git clone\", but not by the manual init+fetch we did\n> above.\n>\n> -Peff\n"}]}