{"thread":{"id":"16200","subject":"Issue updating files during a checkout from a remote push","startedAt":"2008-11-06T17:04:20Z","lastAt":"2008-11-07T21:59:13Z","messageCount":6,"participants":["Steve Walker","Mark Burton","Andreas Ericsson","Jeff King"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"95062","messageId":"334B3AB1-125A-4163-BEBC-9A73C4F569B5@idibu.com","threadId":"16200","inReplyTo":null,"subject":"Issue updating files during a checkout from a remote push","fromName":"Steve Walker","fromEmail":"steve@idibu.com","sentAt":"2008-11-06T17:04:20Z","receivedAt":"2008-11-06T17:04:20Z","isPatch":false,"sender":{"key":"steve@idibu.com","avatar":"https://gravatar.com/avatar/eb463660058a3dd58d078b24c89660795fc46ba5d66c4a9e3e61c40ba75ee758?d=mp&s=160"},"body":"Hi there,\n\nHoping someone could point me in the right direction here.\n\nThe overall issue is that with files that have been pushed into our  \nrepo on our server, when we then check out into local working copy the  \nnew files appear, but the updated files dont update even though the  \noutput suggests it has. The flow I'm doing:\n\n1. The file I'm testing an update to is this:\n\n-rw-r--r--   1 root    www-data       0 2008-11-06 16:13 steve-git- \ntest3.txt\n\n2. On my local box I change file, add it, commit, then push it from my  \nlocal box to our server repo:\n\nStevePoota:public_html steve$ vi steve-git-test3.txt\nStevePoota:public_html steve$ git add steve-git-test3.txt\nStevePoota:public_html steve$ git commit\nCreated commit e29b724: testing only\n  1 files changed, 1 insertions(+), 0 deletions(-)\nStevePoota:public_html steve$ git push ssh://idibu.com/home/beta_idibu/public_html \n  master:master\nCounting objects: 5, done.\nCompressing objects: 100% (2/2), done.\nWriting objects: 100% (3/3), 272 bytes, done.\nTotal 3 (delta 1), reused 0 (delta 0)\nTo ssh://idibu.com/home/beta_idibu/public_html\n    a28332a..e29b724  master -> master\n\n3. It all looks good, on my server if i do a 'git log' I can see in  \nthe latest update:\n\noneworld:/home/beta_idibu/public_html# git log\ncommit e29b7246beab458d6a7b53cb245a5596adc8c198\nAuthor: Steve <steve@StevePoota.local>\nDate:   Thu Nov 6 17:55:21 2008 +0100\n\n     testing only\n\n4. So I check out:\n\noneworld:/home/beta_idibu/public_html# git checkout master\nM\t.gitignore\nM\tsteve-git-test.txt\nM\tsteve-git-test2.txt\nM\tsteve-git-test3.txt\nAlready on branch \"master\"\noneworld:/home/beta_idibu/public_html#\n\nand its telling me that file has been modified\n\nbut checking my file it hasnt changed by date stamp, and looking insie  \nthe file my changes arent there :((\n\n-rw-r--r--   1 root    www-data       0 2008-11-06 16:13 steve-git- \ntest3.txt\n\nI'm stumped. I tried 777'ing that file temporarily in case git couldnt  \nwrite to that file on checkout. What is strange is that when I add new  \nfiles to the system it works - for example this file I'm testing no  \nwas originally added to the server via an external push.\n\nIf anyone could give me some help I'd be very grateful.\n\nKind regards, Steve.\n"},{"id":"95063","messageId":"09C2A669-2B99-4490-9C95-FCCD76C03D61@idibu.com","threadId":"16200","inReplyTo":"334B3AB1-125A-4163-BEBC-9A73C4F569B5@idibu.com","subject":"Re: Issue updating files during a checkout from a remote push","fromName":"Steve Walker","fromEmail":"steve@idibu.com","sentAt":"2008-11-06T17:17:54Z","receivedAt":"2008-11-06T17:17:54Z","isPatch":false,"sender":{"key":"steve@idibu.com","avatar":"https://gravatar.com/avatar/eb463660058a3dd58d078b24c89660795fc46ba5d66c4a9e3e61c40ba75ee758?d=mp&s=160"},"body":"Sorry to keep answering my own questions directly after posting...\n\nI just tried with a 'git commit -f' and the files updated.\n\nCan anyone tell me if this is good practice? I would have thought a  \nnormal commit would update from index to head - isnt always forcing it  \ncreating potentially bad merges?\n\nKind regards, Steve.\n\nOn Nov 6, 2008, at 6:04 PM, Steve Walker wrote:\n\n> Hi there,\n>\n> Hoping someone could point me in the right direction here.\n>\n> The overall issue is that with files that have been pushed into our  \n> repo on our server, when we then check out into local working copy  \n> the new files appear, but the updated files dont update even though  \n> the output suggests it has. The flow I'm doing:\n>\n> 1. The file I'm testing an update to is this:\n>\n> -rw-r--r--   1 root    www-data       0 2008-11-06 16:13 steve-git- \n> test3.txt\n>\n> 2. On my local box I change file, add it, commit, then push it from  \n> my local box to our server repo:\n>\n> StevePoota:public_html steve$ vi steve-git-test3.txt\n> StevePoota:public_html steve$ git add steve-git-test3.txt\n> StevePoota:public_html steve$ git commit\n> Created commit e29b724: testing only\n> 1 files changed, 1 insertions(+), 0 deletions(-)\n> StevePoota:public_html steve$ git push ssh://idibu.com/home/beta_idibu/public_html \n>  master:master\n> Counting objects: 5, done.\n> Compressing objects: 100% (2/2), done.\n> Writing objects: 100% (3/3), 272 bytes, done.\n> Total 3 (delta 1), reused 0 (delta 0)\n> To ssh://idibu.com/home/beta_idibu/public_html\n>   a28332a..e29b724  master -> master\n>\n> 3. It all looks good, on my server if i do a 'git log' I can see in  \n> the latest update:\n>\n> oneworld:/home/beta_idibu/public_html# git log\n> commit e29b7246beab458d6a7b53cb245a5596adc8c198\n> Author: Steve <steve@StevePoota.local>\n> Date:   Thu Nov 6 17:55:21 2008 +0100\n>\n>    testing only\n>\n> 4. So I check out:\n>\n> oneworld:/home/beta_idibu/public_html# git checkout master\n> M\t.gitignore\n> M\tsteve-git-test.txt\n> M\tsteve-git-test2.txt\n> M\tsteve-git-test3.txt\n> Already on branch \"master\"\n> oneworld:/home/beta_idibu/public_html#\n>\n> and its telling me that file has been modified\n>\n> but checking my file it hasnt changed by date stamp, and looking  \n> insie the file my changes arent there :((\n>\n> -rw-r--r--   1 root    www-data       0 2008-11-06 16:13 steve-git- \n> test3.txt\n>\n> I'm stumped. I tried 777'ing that file temporarily in case git  \n> couldnt write to that file on checkout. What is strange is that when  \n> I add new files to the system it works - for example this file I'm  \n> testing no was originally added to the server via an external push.\n>\n> If anyone could give me some help I'd be very grateful.\n>\n> Kind regards, Steve.\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\nwww.idibu.co.uk\nsteve@idibu.com\n\nSales: +44 (0)800 311 2750\nSupport: +44 (0)870 626 4268\nFax: +44 (0)8701 417 136\n\nMobile: +34 661 785 387\nwww.linkedin.com/in/stevejwalker\n"},{"id":"95072","messageId":"loom.20081106T174246-381@post.gmane.org","threadId":"16200","inReplyTo":"09C2A669-2B99-4490-9C95-FCCD76C03D61@idibu.com","subject":"Re: Issue updating files during a checkout from a remote push","fromName":"Mark Burton","fromEmail":"markb@ordern.com","sentAt":"2008-11-06T17:53:05Z","receivedAt":"2008-11-06T17:53:05Z","isPatch":false,"sender":{"key":"markb@ordern.com","avatar":null},"body":"\nHi Steve,\n\nI think you are making the same mistake as I did when I first started using git.\n\nYou can't push to \"master\" from a remote repository because if you do, the index\nand working files associated with the receiving repository look as if they have\nbeen changed because they are out of date WRT the repository.\n\nIf you want to push to a repository that has working files associated with it,\npush to a remote branch in that repository and then merge the contents of the\nremote branch into the working files. I.e. don't push to \"master\", push to\n\"remotes/somename/master\" and then merge somename/master into the master branch.\n\nThat's what I do now to migrate changes from my satellite development machines\nto my master machine.\n\nCheers,\n\nMark\n"},{"id":"95108","messageId":"4913FAA3.3030608@op5.se","threadId":"16200","inReplyTo":"334B3AB1-125A-4163-BEBC-9A73C4F569B5@idibu.com","subject":"Re: Issue updating files during a checkout from a remote push","fromName":"Andreas Ericsson","fromEmail":"ae@op5.se","sentAt":"2008-11-07T08:21:55Z","receivedAt":"2008-11-07T08:21:55Z","isPatch":false,"sender":{"key":"ae@op5.se","avatar":"https://gravatar.com/avatar/426e89595c75a8f5252dd0c989e5fabe5bcac616e68557427ad9aef6b0ca342a?d=mp&s=160"},"body":"Steve Walker wrote:\n> Hi there,\n> \n> Hoping someone could point me in the right direction here.\n> \n> The overall issue is that with files that have been pushed into our repo \n> on our server, when we then check out into local working copy the new \n> files appear, but the updated files dont update even though the output \n> suggests it has. The flow I'm doing:\n> \n> 1. The file I'm testing an update to is this:\n> \n> -rw-r--r--   1 root    www-data       0 2008-11-06 16:13 \n> steve-git-test3.txt\n> \n> 2. On my local box I change file, add it, commit, then push it from my \n> local box to our server repo:\n> \n> StevePoota:public_html steve$ vi steve-git-test3.txt\n> StevePoota:public_html steve$ git add steve-git-test3.txt\n> StevePoota:public_html steve$ git commit\n> Created commit e29b724: testing only\n>  1 files changed, 1 insertions(+), 0 deletions(-)\n> StevePoota:public_html steve$ git push \n> ssh://idibu.com/home/beta_idibu/public_html master:master\n> Counting objects: 5, done.\n> Compressing objects: 100% (2/2), done.\n> Writing objects: 100% (3/3), 272 bytes, done.\n> Total 3 (delta 1), reused 0 (delta 0)\n> To ssh://idibu.com/home/beta_idibu/public_html\n>    a28332a..e29b724  master -> master\n> \n> 3. It all looks good, on my server if i do a 'git log' I can see in the \n> latest update:\n> \n> oneworld:/home/beta_idibu/public_html# git log\n> commit e29b7246beab458d6a7b53cb245a5596adc8c198\n> Author: Steve <steve@StevePoota.local>\n> Date:   Thu Nov 6 17:55:21 2008 +0100\n> \n>     testing only\n> \n> 4. So I check out:\n> \n> oneworld:/home/beta_idibu/public_html# git checkout master\n> M    .gitignore\n> M    steve-git-test.txt\n> M    steve-git-test2.txt\n> M    steve-git-test3.txt\n> Already on branch \"master\"\n> oneworld:/home/beta_idibu/public_html#\n> \n> and its telling me that file has been modified\n> \n> but checking my file it hasnt changed by date stamp, and looking insie \n> the file my changes arent there :((\n> \n> -rw-r--r--   1 root    www-data       0 2008-11-06 16:13 \n> steve-git-test3.txt\n> \n> I'm stumped. I tried 777'ing that file temporarily in case git couldnt \n> write to that file on checkout. What is strange is that when I add new \n> files to the system it works - for example this file I'm testing no was \n> originally added to the server via an external push.\n> \n> If anyone could give me some help I'd be very grateful.\n> \n\ngit reset --hard master\n\nNote that it's definitely not a good idea to push into a non-bare repo\nwhere you modify the worktree, as the workflow requires that you simply\nclobber them (or work on a separate branch and then merge with master,\nbut then you'll have to know *why* things happen and how to fix them).\n\nYou'd probably be better off pushing to another repository and fetching\nfrom that other repo into the non-bare one you're using now.\n\n-- \nAndreas Ericsson                   andreas.ericsson@op5.se\nOP5 AB                             www.op5.se\nTel: +46 8-230225                  Fax: +46 8-230231\n"},{"id":"95149","messageId":"20081107215655.GA20126@coredump.intra.peff.net","threadId":"16200","inReplyTo":"334B3AB1-125A-4163-BEBC-9A73C4F569B5@idibu.com","subject":"Re: Issue updating files during a checkout from a remote push","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-07T21:56:55Z","receivedAt":"2008-11-07T21:56:55Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 06, 2008 at 06:04:20PM +0100, Steve Walker wrote:\n\n> The overall issue is that with files that have been pushed into our repo \n> on our server, when we then check out into local working copy the new \n> files appear, but the updated files dont update even though the output \n> suggests it has. The flow I'm doing:\n\nThe short answer is: don't push into the current branch of a non-bare\nrepo.\n\n> 2. On my local box I change file, add it, commit, then push it from my  \n> local box to our server repo:\n\nOK, so this updates the HEAD of the receiving repository. But the index\nand working tree are untouched.\n\n> 3. It all looks good, on my server if i do a 'git log' I can see in the \n> latest update:\n\nRight, because the HEAD has been updated.\n\n> 4. So I check out:\n>\n> oneworld:/home/beta_idibu/public_html# git checkout master\n> M\t.gitignore\n> M\tsteve-git-test.txt\n> M\tsteve-git-test2.txt\n> M\tsteve-git-test3.txt\n> Already on branch \"master\"\n> oneworld:/home/beta_idibu/public_html#\n\nBut you were already _on_ master, so git shouldn't need to touch the\nindex and working tree. But the contents of master have changed out from\nunder you, so it looks like you have modifications.\n\nSo generally you don't want to push to the current branch, but there is\nno safety valve disallowing it (and I will post a patch series in a\nminute which introduces one). In the past, people have suggested doing a\nmerge with the working tree, but that is not desirable for two reasons:\n\n  1. you are changing the working tree out from under whoever's repo you\n     push into\n\n  2. the merge might not be clean, in which case the user needs to\n     resolve conflicts. But the user isn't even doing stuff in the\n     now-conflicted repository. So the suggested workflow is instead to\n     go to that repo and do a 'pull'\n\nSo depending on what you want to accomplish, there are a number of\nalternative workflows:\n\n - if you just want to publish refs, you can use a bare repo without a\n   working tree at all (git --bare init, or git clone --bare).\n\n - if you just want to throw away working tree changes on a push (e.g.,\n   you are pushing to a production server whose working tree is kept up\n   to date), you can do that automatically with a post-receive hook. But\n   it will never be the default, because we don't want to throw anything\n   away unless the user has explicitly told us to do so.\n\n - if you are working in repos A and B, and you want to get changes from\n   B to A, then you would generally go to A and \"git pull B\". But\n   sometimes that is not possible (e.g., you can only make network\n   connections one way). In that case, you can push to a \"remote\" branch\n   on A, and then merge from there when you're at A. E.g.,:\n\n     /repo/B$ git push /repo/A master:refs/remotes/B/master\n     /repo/B$ cd /repo/A\n     /repo/A$ git merge B/master\n\n-Peff\n"},{"id":"95150","messageId":"20081107215913.GB20126@coredump.intra.peff.net","threadId":"16200","inReplyTo":"09C2A669-2B99-4490-9C95-FCCD76C03D61@idibu.com","subject":"Re: Issue updating files during a checkout from a remote push","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-11-07T21:59:13Z","receivedAt":"2008-11-07T21:59:13Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Thu, Nov 06, 2008 at 06:17:54PM +0100, Steve Walker wrote:\n\n> Sorry to keep answering my own questions directly after posting...\n>\n> I just tried with a 'git commit -f' and the files updated.\n\nThere is no \"-f\" option to commit. Did you mean \"checkout -f\"?\n\nIf that is the case, then yes, that will \"fix\" your problem in that it\nbrings the HEAD, index, and working tree into sync. But it is dangerous\nin that it throws away any local changes you might have had.\n\nIf you did really mean \"commit\" then that is also a bad solution. It\ncreates a new commit on top of the recently pushed work that reverts all\nof the changes made by the recently pushed work.\n\n-Peff\n"}]}