{"thread":{"id":"21805","subject":"Newbie \"svn update\" question","startedAt":"2009-12-01T09:25:37Z","lastAt":"2009-12-01T12:00:22Z","messageCount":4,"participants":["Mikko Oksalahti","Howard Miller","Tay Ray Chuan"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"128855","messageId":"loom.20091201T101313-496@post.gmane.org","threadId":"21805","inReplyTo":null,"subject":"Newbie \"svn update\" question","fromName":"Mikko Oksalahti","fromEmail":"mikko@azila.fi","sentAt":"2009-12-01T09:25:37Z","receivedAt":"2009-12-01T09:25:37Z","isPatch":false,"sender":{"key":"mikko@azila.fi","avatar":null},"body":"Hi,\n\nI just started using git for my personal projects at home. Basic usage seems \npretty straight-forward as well as setting up everything. However, I have a \nsimple question about how do I mimic an \"svn update\" command on a locally \ncreated repository. Here's what I do:\n\nsome_existing_project_dir> git init\nsome_existing_project_dir> git add .\n\n(about 1000 files added...)\n\nsome_existing_project_dir> git commit -a -m \"initial commit\"\n\n(now I edit 10 files and accidentally delete some files that I'm not aware of)\n\nHow do I now get the accidentally deleted files back from the repository without \nlosing local changes made to 10 files? \n\nI've tried using: \"git checkout HEAD .\" but my local changes after last commit \nwill be lost.\n\nI've tried using: \"git pull .\" but the deleted files are not restored.\n\nSo I'm looking for an \"svn update\" equivalent command that would semantically do \nthis: \"Get the latest version of all files from the repository and merge them \nwith any local changes I've made to files.\"\n\nI know a suitable command is available and I'm just a moron who can't read the \nmanual correctly but help me out anyway :P\n\n  Regards,\n     Mikko\n"},{"id":"128857","messageId":"26ae428a0912010145k61dbfc41l8243363493918445@mail.gmail.com","threadId":"21805","inReplyTo":"loom.20091201T101313-496@post.gmane.org","subject":"Re: Newbie \"svn update\" question","fromName":"Howard Miller","fromEmail":"howardsmiller@googlemail.com","sentAt":"2009-12-01T09:45:20Z","receivedAt":"2009-12-01T09:45:20Z","isPatch":false,"sender":{"key":"howardsmiller@googlemail.com","avatar":"https://gravatar.com/avatar/69a7274bc5c4c66910b00e4ea6590e46e2325b53ff4807854f3ed469b49400b1?d=mp&s=160"},"body":"2009/12/1 Mikko Oksalahti <mikko@azila.fi>:\n> Hi,\n>\n> I just started using git for my personal projects at home. Basic usage seems\n> pretty straight-forward as well as setting up everything. However, I have a\n> simple question about how do I mimic an \"svn update\" command on a locally\n> created repository. Here's what I do:\n>\n> some_existing_project_dir> git init\n> some_existing_project_dir> git add .\n>\n> (about 1000 files added...)\n>\n> some_existing_project_dir> git commit -a -m \"initial commit\"\n>\n> (now I edit 10 files and accidentally delete some files that I'm not aware of)\n>\n> How do I now get the accidentally deleted files back from the repository without\n> losing local changes made to 10 files?\n>\n> I've tried using: \"git checkout HEAD .\" but my local changes after last commit\n> will be lost.\n>\n> I've tried using: \"git pull .\" but the deleted files are not restored.\n>\n> So I'm looking for an \"svn update\" equivalent command that would semantically do\n> this: \"Get the latest version of all files from the repository and merge them\n> with any local changes I've made to files.\"\n>\n> I know a suitable command is available and I'm just a moron who can't read the\n> manual correctly but help me out anyway :P\n>\n>  Regards,\n>     Mikko\n\n'git status' should show you what files you have deleted.  'git\ncheckout filename' should get them back. I can't think of a way of\nrecovering every file you have just deleted although - I suspect it\nmight be tricky. Thinks like 'git pull' only apply to remote\nrepositories and you don't have one of those. You're not thinking of\nit the right way (yet) :-)\n\nHoward\n"},{"id":"128858","messageId":"be6fef0d0912010149o5b5d0557xfb8c57e4a29e4d7e@mail.gmail.com","threadId":"21805","inReplyTo":"loom.20091201T101313-496@post.gmane.org","subject":"Re: Newbie \"svn update\" question","fromName":"Tay Ray Chuan","fromEmail":"rctay89@gmail.com","sentAt":"2009-12-01T09:49:59Z","receivedAt":"2009-12-01T09:49:59Z","isPatch":false,"sender":{"key":"rctay89@gmail.com","avatar":"https://avatars.githubusercontent.com/u/61553?v=4"},"body":"Hi\n\nOn Tue, Dec 1, 2009 at 5:25 PM, Mikko Oksalahti <mikko@azila.fi> wrote:\n> How do I now get the accidentally deleted files back from the repository without\n> losing local changes made to 10 files?\n>\n> I've tried using: \"git checkout HEAD .\" but my local changes after last commit\n> will be lost.\n>\n> I've tried using: \"git pull .\" but the deleted files are not restored.\n>\n> So I'm looking for an \"svn update\" equivalent command that would semantically do\n> this: \"Get the latest version of all files from the repository and merge them\n> with any local changes I've made to files.\"\n\nAre you looking for a command that\n\n  \"Restore deleted files, without reverting local changes\",\n\nor\n\n  \"Get the latest version of all files from the repository and merge\nthem with any local changes I've made to files.\"?\n\nI would suggest adding the changed files, then doing a checkout.\n\n  git add changed.file1\n  git add changed.file2\n  git add -p #alternatively, select hunks/changes to add interactively\n  git checkout HEAD #although using . (current directory) should give\nthe same result\n\nNote that your changes have only been added to the index, and you need\nto commit them. The index/stage is a concept not in svn. See the user\nmanual for more on this.\n\nI also suspect you are still thinking in svn mode when you said\ngetting the latest version from the repository. You already have a\nrepository locally. It is more an issue of syncing your local\nrepository with the one that you're following. Unlike svn, every time\nyou commit, your local repository is updated, not the remote one, and\nvice-versa.\n\n-- \nCheers,\nRay Chuan\n"},{"id":"128867","messageId":"loom.20091201T125555-549@post.gmane.org","threadId":"21805","inReplyTo":"26ae428a0912010145k61dbfc41l8243363493918445@mail.gmail.com","subject":"Re: Newbie","fromName":"Mikko Oksalahti","fromEmail":"mikko@azila.fi","sentAt":"2009-12-01T12:00:22Z","receivedAt":"2009-12-01T12:00:22Z","isPatch":false,"sender":{"key":"mikko@azila.fi","avatar":null},"body":"Howard Miller <howardsmiller <at> googlemail.com> writes:\n\n> \n> 2009/12/1 Mikko Oksalahti <mikko <at> azila.fi>:\n> > How do I now get the accidentally deleted files back from the repository \nwithout\n> > losing local changes made to 10 files?\n> \n> 'git status' should show you what files you have deleted.  'git\n> checkout filename' should get them back. I can't think of a way of\n> recovering every file you have just deleted although - I suspect it\n> might be tricky. Thinks like 'git pull' only apply to remote\n> repositories and you don't have one of those. \n> \n> Howard\n> \n\nOk. That helps. I just assumed the 'git pull' would work same way on local and \nremote repositories but I guess not then...\n\n> ....You're not thinking of it the right way (yet) \n\nI hate when you say that :P\n\n  /Mikko\n"}]}