{"thread":{"id":"16852","subject":"Question with git push","startedAt":"2008-12-23T16:59:10Z","lastAt":"2008-12-23T17:37:47Z","messageCount":3,"participants":["Paul Vincent Craven","Peter Harris","demerphq"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"98623","messageId":"5591393c0812230859n3b50b1f9k36153f40dd75ff57@mail.gmail.com","threadId":"16852","inReplyTo":null,"subject":"Question with git push","fromName":"Paul Vincent Craven","fromEmail":"paul@cravenfamily.com","sentAt":"2008-12-23T16:59:10Z","receivedAt":"2008-12-23T16:59:10Z","isPatch":false,"sender":{"key":"paul@cravenfamily.com","avatar":null},"body":"If I do a 'git push' to another repository, my changes are reverted\nthe next time that repository is updated, unless I do a hard reset on\nthe remote repository first. Of course, then I would lose my changes\nin the remote repository. What is the correct way of handling this?\n\nA quick example:\n\nmkdir -p RepositoryA/files RepositoryB\ncd RepositoryA/files\necho \"Test file\" > test1.txt\ngit init\ngit add .\ngit commit -a -m \"Test Commit 1\"\ncd ../../RepositoryB\ngit clone ../RepositoryA/files\ncd files\n# I want this change to go to RepositoryA\necho \"More data\" >> test1.txt\ngit add .\ngit commit -a -m \"Test Commit 2\"\ngit push ../../RepositoryA/files\ncd ../../RepositoryA/files\necho \"Test file\" > test2.txt\ngit add .\n# This commit reverts test1.txt to not have \"More data\"\ngit commit -a -m \"Test Commit 3\" # This reverts test1.txt to not\ngit diff master^ master\n\nHow do I change my commands so I keep the change I made in RepositoryB?\n\nThanks,\n\n-- \nPaul Vincent Craven\n\n--\nPaul Vincent Craven\nhttp://www.cravenfamily.com\n"},{"id":"98626","messageId":"eaa105840812230935o63ac7960h728c905da12b8cc0@mail.gmail.com","threadId":"16852","inReplyTo":"5591393c0812230859n3b50b1f9k36153f40dd75ff57@mail.gmail.com","subject":"Re: Question with git push","fromName":"Peter Harris","fromEmail":"git@peter.is-a-geek.org","sentAt":"2008-12-23T17:35:50Z","receivedAt":"2008-12-23T17:35:50Z","isPatch":false,"sender":{"key":"git@peter.is-a-geek.org","avatar":null},"body":"On Tue, Dec 23, 2008 at 11:59 AM, Paul Vincent Craven wrote:\n> If I do a 'git push' to another repository, my changes are reverted\n> the next time that repository is updated, unless I do a hard reset on\n> the remote repository first. Of course, then I would lose my changes\n> in the remote repository. What is the correct way of handling this?\n\nPull from the other side, or push to a branch that you never check\nout. Better yet, push to a bare (no work tree) repo you can pull from\nboth sides.\n\nhttp://git.or.cz/gitwiki/GitFaq#head-b96f48bc9c925074be9f95c0fce69bcece5f6e73\n\nPeter Harris\n"},{"id":"98627","messageId":"9b18b3110812230937p3c53f778h508746a3df72610e@mail.gmail.com","threadId":"16852","inReplyTo":"5591393c0812230859n3b50b1f9k36153f40dd75ff57@mail.gmail.com","subject":"Re: Question with git push","fromName":"demerphq","fromEmail":"demerphq@gmail.com","sentAt":"2008-12-23T17:37:47Z","receivedAt":"2008-12-23T17:37:47Z","isPatch":false,"sender":{"key":"demerphq@gmail.com","avatar":null},"body":"2008/12/23 Paul Vincent Craven <paul@cravenfamily.com>:\n> If I do a 'git push' to another repository, my changes are reverted\n> the next time that repository is updated, unless I do a hard reset on\n> the remote repository first.\n\nOr just git checkout -f\n\n> Of course, then I would lose my changes\n> in the remote repository. What is the correct way of handling this?\n\nI think the general practice is not to push to non-bare repositories\nunless you and the owner of the repository can coordinate things. This\neither means you push and then tell them, or they set up a\npost-receive hook (and understand the consequences of doing so). Of\ncourse often you are both of these people and coordination is easy.\n\nThe post-receive hook would go in .git/hooks and would effectively execute:\n\n  git checkout -f\n\non push. However this also means that the working directory will be\nunilaterally updated every time someone pushes. Not something you want\nto do in a truely shared non-bare repo.\nYves\n\n\n-- \nperl -Mre=debug -e \"/just|another|perl|hacker/\"\n"}]}