{"thread":{"id":"30720","subject":"How to pull force just one folder in dev tree?","startedAt":"2012-06-05T17:41:40Z","lastAt":"2012-06-11T20:18:49Z","messageCount":3,"participants":["J.V.","Junio C Hamano","Philip Oakley"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"192934","messageId":"4FCE44D4.6050805@gmail.com","threadId":"30720","inReplyTo":null,"subject":"How to pull force just one folder in dev tree?","fromName":"J.V.","fromEmail":"jvsrvcs@gmail.com","sentAt":"2012-06-05T17:41:40Z","receivedAt":"2012-06-05T17:41:40Z","isPatch":false,"sender":{"key":"jvsrvcs@gmail.com","avatar":null},"body":"If I am in my source code tree down deep in a directory at the command \nline, how do I pull from a repo and force overwrite all files locally \n(and also get files that I deleted locally, just in the folder I am in?)\n\nI do not want to do this for the entire repo, just the directory that I \nam in and also on the branch I am in.  I am not in the 'master' branch, \nbut another branch.\n\nso\n\n  $git reset --hard HEAD\n\n  Would probably do my entire local repo and from 'master' (even if I am \nnot on master)?\n\n---\nI want to git force pull from the branch I am on locally (tracked to a \nbranch on a remote bare repo) and force overwrite of all files locally & \nalso get the files I may have deleted locally from the file system (not \nfiles deleted through git).\n\nHow do I practice this to see what would happen (or revert) your \nsolution if there are problems?\n"},{"id":"192939","messageId":"7vlik1obdg.fsf@alter.siamese.dyndns.org","threadId":"30720","inReplyTo":"4FCE44D4.6050805@gmail.com","subject":"Re: How to pull force just one folder in dev tree?","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2012-06-05T18:35:23Z","receivedAt":"2012-06-05T18:35:23Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"J.V.\" <jvsrvcs@gmail.com> writes:\n\n> If I am in my source code tree down deep in a directory at the command\n> line, how do I pull from a repo and force overwrite all files locally\n> (and also get files that I deleted locally, just in the folder I am\n> in?)\n>\n> I do not want to do this for the entire repo, just the directory that\n> I am in and also on the branch I am in.  I am not in the 'master'\n> branch, but another branch.\n>\n> so\n>\n>  $git reset --hard HEAD\n>\n>  Would probably do my entire local repo and from 'master' (even if I\n> am not on master)?\n\nNo. It asks \"Please reset the index and the working tree files to\nmatch what I have in the commit I checked out\".  If you are on the\n'slave' branch, the index and the working tree files are updated to\nmatch the commit at the tip of the 'slave' branch.\n\nIt is unclear what you are trying to do, but if you made random\nchanges in files in your current directory (somewhere deep), all\nchanges are crap and you regret making them, and you are wishing to\ngo back to the state you started from, then the way to ask \"I want\neverything in this directory checked out from my current branch\" is\nto say:\n\n\t$ git checkout HEAD -- .\n"},{"id":"193368","messageId":"8F71F33B20804F85AC15F77A30855D1C@PhilipOakley","threadId":"30720","inReplyTo":"7vlik1obdg.fsf@alter.siamese.dyndns.org","subject":"Re: How to pull force just one folder in dev tree?","fromName":"Philip Oakley","fromEmail":"philipoakley@iee.org","sentAt":"2012-06-11T20:18:49Z","receivedAt":"2012-06-11T20:18:49Z","isPatch":false,"sender":{"key":"philipoakley@iee.email","avatar":"https://avatars.githubusercontent.com/u/914343?v=4"},"body":"From: \"Junio C Hamano\" <gitster@pobox.com>\nTo: \"J.V.\" <jvsrvcs@gmail.com>\nCc: <git@vger.kernel.org>\nSent: Tuesday, June 05, 2012 7:35 PM\nSubject: Re: How to pull force just one folder in dev tree?\n\n\n> \"J.V.\" <jvsrvcs@gmail.com> writes:\n>\n>> If I am in my source code tree down deep in a directory at the\n>> command\n>> line, how do I pull from a repo and force overwrite all files locally\n>> (and also get files that I deleted locally, just in the folder I am\n>> in?)\n\nI think the particular command for this case would be\n    git checkout [-p|--patch] [<tree-ish>] [--] [<paths>.]\nwhere the paths are defined as a pathspec (see git glossary for\ndetails).\n\nThough you should review how you got into this sticky situation and\nconsider  how you would adjust your workflow so you don't repeat the\nproblem.\ne.g. creating a temporary branch earlier, with more commits or stashes.\n\n>>\n>> I do not want to do this for the entire repo, just the directory that\n>> I am in and also on the branch I am in.  I am not in the 'master'\n>> branch, but another branch.\n>>\n>> so\n>>\n>>  $git reset --hard HEAD\n>>\n>>  Would probably do my entire local repo and from 'master' (even if I\n>> am not on master)?\n>\n> No. It asks \"Please reset the index and the working tree files to\n> match what I have in the commit I checked out\".  If you are on the\n> 'slave' branch, the index and the working tree files are updated to\n> match the commit at the tip of the 'slave' branch.\n>\n> It is unclear what you are trying to do, but if you made random\n> changes in files in your current directory (somewhere deep), all\n> changes are crap and you regret making them, and you are wishing to\n> go back to the state you started from, then the way to ask \"I want\n> everything in this directory checked out from my current branch\" is\n> to say:\n>\n> $ git checkout HEAD -- .\n>\n> --\n> To unsubscribe from this list: send the line \"unsubscribe git\" in\n> the body of a message to majordomo@vger.kernel.org\n> More majordomo info at  http://vger.kernel.org/majordomo-info.html\n>\n>\n> -----\n> No virus found in this message.\n> Checked by AVG - www.avg.com\n> Version: 2012.0.2178 / Virus Database: 2433/5048 - Release Date:\n> 06/05/12\n>\n"}]}