{"thread":{"id":"16119","subject":"git reset --hard w/o touching every file","startedAt":"2008-11-01T04:48:38Z","lastAt":"2008-11-02T05:52:12Z","messageCount":6,"participants":["Edward Z. Yang","Pierre Habouzit","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"94534","messageId":"gegn38$lku$1@ger.gmane.org","threadId":"16119","inReplyTo":null,"subject":"git reset --hard w/o touching every file","fromName":"Edward Z. Yang","fromEmail":"edwardzyang@thewritingpot.com","sentAt":"2008-11-01T04:48:38Z","receivedAt":"2008-11-01T04:48:38Z","isPatch":false,"sender":{"key":"edwardzyang@thewritingpot.com","avatar":"https://gravatar.com/avatar/a805a0a3c1d7d36e7fe22270596e4d812723652933c59cac267e67c79126fdd0?d=mp&s=160"},"body":"I was wondering if there was any way to run `git reset --hard $revlike`,\nor a command with the same effect, without having Git touch every file?\n\nCheers,\nEdward\n"},{"id":"94547","messageId":"20081101110529.GC3819@artemis.corp","threadId":"16119","inReplyTo":"gegn38$lku$1@ger.gmane.org","subject":"Re: git reset --hard w/o touching every file","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-11-01T11:05:29Z","receivedAt":"2008-11-01T11:05:29Z","isPatch":false,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Sat, Nov 01, 2008 at 04:48:38AM +0000, Edward Z. Yang wrote:\n> I was wondering if there was any way to run `git reset --hard $revlike`,\n> or a command with the same effect, without having Git touch every file?\n\ngit checkout HEAD -- <list of the files>\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"94584","messageId":"geicn8$ss8$1@ger.gmane.org","threadId":"16119","inReplyTo":"20081101110529.GC3819@artemis.corp","subject":"Re: git reset --hard w/o touching every file","fromName":"Edward Z. Yang","fromEmail":"edwardzyang@thewritingpot.com","sentAt":"2008-11-01T20:03:50Z","receivedAt":"2008-11-01T20:03:50Z","isPatch":false,"sender":{"key":"edwardzyang@thewritingpot.com","avatar":"https://gravatar.com/avatar/a805a0a3c1d7d36e7fe22270596e4d812723652933c59cac267e67c79126fdd0?d=mp&s=160"},"body":"Pierre Habouzit wrote:\n> git checkout HEAD -- <list of the files>\n\nWhat if I do not know a priori which files *do* need to be updated? Is\nthere a command that I can get this information from? Also, I may not\nnecessarily be checking out HEAD.\n"},{"id":"94618","messageId":"20081102033313.GB4936@coredump.intra.peff.net","threadId":"16119","inReplyTo":"geicn8$ss8$1@ger.gmane.org","subject":"Re: git reset --hard w/o touching every file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-02T03:33:13Z","receivedAt":"2008-11-02T03:33:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Nov 01, 2008 at 04:03:50PM -0400, Edward Z. Yang wrote:\n\n> Pierre Habouzit wrote:\n> > git checkout HEAD -- <list of the files>\n> \n> What if I do not know a priori which files *do* need to be updated? Is\n> there a command that I can get this information from? Also, I may not\n\nSorry, I don't quite understand. You want to check out some subset of\nfiles, but you don't know which subset?\n\nTry \"git status\" or \"git diff\" to look at which files have changes?\n\nOr maybe we didn't understand your original question.\n\n> necessarily be checking out HEAD.\n\nDoing\n\n  git checkout v1.5 -- <list of files>\n\nor using any other ref will work just fine.\n\n-Peff\n"},{"id":"94627","messageId":"gejanr$os$1@ger.gmane.org","threadId":"16119","inReplyTo":"20081102033313.GB4936@coredump.intra.peff.net","subject":"Re: git reset --hard w/o touching every file","fromName":"Edward Z. Yang","fromEmail":"edwardzyang@thewritingpot.com","sentAt":"2008-11-02T04:36:09Z","receivedAt":"2008-11-02T04:36:09Z","isPatch":false,"sender":{"key":"edwardzyang@thewritingpot.com","avatar":"https://gravatar.com/avatar/a805a0a3c1d7d36e7fe22270596e4d812723652933c59cac267e67c79126fdd0?d=mp&s=160"},"body":"Jeff King wrote:\n> Sorry, I don't quite understand. You want to check out some subset of\n> files, but you don't know which subset?\n\nYeah, I should elaborate a little.\n\nI'm using a script to automatically update a website with the contents\nof a Git repository at a specified interval. While I could use git pull,\nI've been told that it's safer to do a git fetch, and then a git reset\n--hard remotes/master, because the former could trigger a merge and on a\nlive website that is NOT desirable.\n\nUnfortunately, since Git touches all files on a reset --hard, it's\ncausing problems with the smart cache system, which checks whether or\nnot the cache file is older than the source file, and regenerating if it is.\n\nCheers,\nEdward\n"},{"id":"94631","messageId":"20081102055212.GG5261@coredump.intra.peff.net","threadId":"16119","inReplyTo":"gejanr$os$1@ger.gmane.org","subject":"Re: git reset --hard w/o touching every file","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-02T05:52:12Z","receivedAt":"2008-11-02T05:52:12Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sun, Nov 02, 2008 at 12:36:09AM -0400, Edward Z. Yang wrote:\n\n> I'm using a script to automatically update a website with the contents\n> of a Git repository at a specified interval. While I could use git pull,\n> I've been told that it's safer to do a git fetch, and then a git reset\n> --hard remotes/master, because the former could trigger a merge and on a\n> live website that is NOT desirable.\n\nWell, there will never be a merge if you aren't making local changes\n(and your upstream is not doing silly things like rewinding the history of\nwhat it gives you). But if you aren't making local changes, then doing a\nreset is \"safe\" in the sense that you will have nothing to throw away.\n\n> Unfortunately, since Git touches all files on a reset --hard, it's\n> causing problems with the smart cache system, which checks whether or\n> not the cache file is older than the source file, and regenerating if\n> it is.\n\nAh, OK. I see what you want.\n\nGit usually tries very hard not to touch files that don't need to be\ntouched. So that sounds like a bug. However, I can't reproduce it with\nthis test case:\n\n    mkdir repo && cd repo && git init &&\n    touch a b && git add a b && git commit -m added &&\n    echo changes >a && git commit -a -m 'changed a' &&\n    touch -d 1979-10-12 a b && echo before reset && ls -l a b &&\n    git update-index --refresh &&\n    git reset --hard HEAD^ && echo after reset && ls -l a b\n\nI end up with:\n\n    before reset\n    -rw-r--r-- 1 peff peff 8 1979-10-12 00:00 a\n    -rw-r--r-- 1 peff peff 0 1979-10-12 00:00 b\n    HEAD is now at d7fd84e added\n    after reset\n    -rw-r--r-- 1 peff peff 0 2008-11-02 01:46 a\n    -rw-r--r-- 1 peff peff 0 1979-10-12 00:00 b\n\nwhich makes sense. The only tricky thing is the \"update-index --refresh\"\ncall, which basically tells git \"update your cache with the new mtime\nvalue\", which is necessary because of the contrived use of \"touch\". But\nif you are manipulating these files only through \"git reset\", it should\nJust Work.\n\n-Peff\n"}]}