{"thread":{"id":"25975","subject":"git fetch vs push, git am questions","startedAt":"2010-12-06T20:27:55Z","lastAt":"2010-12-09T13:57:11Z","messageCount":5,"participants":["Konstantin Kivi","Konstantin Khomoutov","Neal Kreitzinger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"157427","messageId":"99351291667275@web152.yandex.ru","threadId":"25975","inReplyTo":null,"subject":"git fetch vs push, git am questions","fromName":"Konstantin Kivi","fromEmail":"kkivi@yandex.ru","sentAt":"2010-12-06T20:27:55Z","receivedAt":"2010-12-06T20:27:55Z","isPatch":false,"sender":{"key":"kkivi@yandex.ru","avatar":null},"body":"HI all\nI honestly tried to find answers in various docs/books about git and failed, so I have to ask here.\n \n1) Is it possible to achieve the same result with git fetch, as I have with git push. I have cloned a bare repository (2) from my repository (1) and \nI want fetch made in (2) get all info contained in (1) . I talk only about 'master' here. git push from (1) to (2) does the job, but git fetch in (1) updates only origin/master, and not master.\nI also found that there is a notions of current branch in bare repository (master in my case), that stops my experiments of deleting master and making new master out of origin/master.\nHow can I change current branch in bare repositry?\n \n2) I read that git rebase used 'git am' internally. How can  force git am/apply to create conflicts like rebase does in form\n \n<<<<<<old\ndksjfd\n========\n>>>>>jfkjdfkd\n \ninstead of *.rej files \n\nBest regard, Konstantin\n"},{"id":"157471","messageId":"20101207002104.GG3264@localhost.localdomain","threadId":"25975","inReplyTo":"99351291667275@web152.yandex.ru","subject":"Re: git fetch vs push, git am questions","fromName":"Konstantin Khomoutov","fromEmail":"flatworm@users.sourceforge.net","sentAt":"2010-12-07T00:21:04Z","receivedAt":"2010-12-07T00:21:04Z","isPatch":false,"sender":{"key":"flatworm@users.sourceforge.net","avatar":null},"body":"On Mon, Dec 06, 2010 at 11:27:55PM +0300, Konstantin Kivi wrote:\n\n[...]\n> 1) Is it possible to achieve the same result with git fetch, as I have\n> with git push. I have cloned a bare repository (2) from my repository\n> (1) and I want fetch made in (2) get all info contained in (1) . I\n> talk only about 'master' here. git push from (1) to (2) does the job,\n> but git fetch in (1) updates only origin/master, and not master.\n`git pull` does exactly that: fetch + merge (which should result in\nfast-forward in your case).\n\n> I also found that there is a notions of current branch in bare\n> repository (master in my case), that stops my experiments of deleting\n> master and making new master out of origin/master.  How can I change\n> current branch in bare repositry?\nBy re-writing the HEAD ref (this behaviour is documented in the man page\nof the `git clone` command, see the \"--branch\" option for instance).\nYou can use the `git symbolic-ref` to update the HEAD ref.\n\n[...]\n\nP.S.\nIt's a bit strange you're playing with a bare repository in this way.\nUsually a bare repository is supposed to be pushed to and pulled from,\nnot the other way round. Not that it's bad, but it may turn out you're\ninventing a convoluted workflow when there may be a simpler solution.\n"},{"id":"157485","messageId":"60371291725083@web106.yandex.ru","threadId":"25975","inReplyTo":"20101207002104.GG3264@localhost.localdomain","subject":"Re: git fetch vs push, git am questions","fromName":"Konstantin Kivi","fromEmail":"kkivi@yandex.ru","sentAt":"2010-12-07T12:31:23Z","receivedAt":"2010-12-07T12:31:23Z","isPatch":false,"sender":{"key":"kkivi@yandex.ru","avatar":null},"body":"\n\n07.12.10, 03:21, \"Konstantin Khomoutov\" <flatworm@users.sourceforge.net>:\n\n\n>  `git pull` does exactly that: fetch + merge (which should result in\n>  fast-forward in your case).\n\npull does not work on bare repos.\n\n>  > I also found that there is a notions of current branch in bare repository\n> >  How can I change current branch in bare repositry?\n\nI think I will understand things better if I get what is 'current branch' for bare repository\nand how to change it\n\n>  By re-writing the HEAD ref (this behaviour is documented in the man page\n>  of the `git clone` command, see the \"--branch\" option for instance).\n\nThe repository already exists, so git-clone  will not help\n\n>  You can use the `git symbolic-ref` to update the HEAD ref.\n>  \n\nDo you mean something like \ngit symbolic-ref  master origin/master ?\n\n\n>  [...]\n>  \n>  P.S.\n>  It's a bit strange you're playing with a bare repository in this way.\n>  Usually a bare repository is supposed to be pushed to and pulled from,\n>  not the other way round. Not that it's bad, but it may turn out you're\n>  inventing a convoluted workflow when there may be a simpler solution.\n\nYes, I see that push is easier, I only want to be sure I have full control on what is going on.\n\n\n-- \nС уважением, Константин Киви\n"},{"id":"157529","messageId":"idm4j0$ov1$1@dough.gmane.org","threadId":"25975","inReplyTo":"99351291667275@web152.yandex.ru","subject":"Re: git fetch vs push, git am questions","fromName":"Neal Kreitzinger","fromEmail":"neal@rsss.com","sentAt":"2010-12-07T20:14:04Z","receivedAt":"2010-12-07T20:14:04Z","isPatch":false,"sender":{"key":"neal@rsss.com","avatar":null},"body":"\"Konstantin Kivi\" <kkivi@yandex.ru> wrote in message \nnews:99351291667275@web152.yandex.ru...\n> HI all\n> I honestly tried to find answers in various docs/books about git and \n> failed, so I have to ask here.\n>\n> 1) Is it possible to achieve the same result with git fetch, as I have \n> with git push. I have cloned a bare repository (2) from my repository (1) \n> and\n> I want fetch made in (2) get all info contained in (1) . I talk only about \n> 'master' here. git push from (1) to (2) does the job, but git fetch in (1) \n> updates only origin/master, and not master.\n> I also found that there is a notions of current branch in bare repository \n> (master in my case), that stops my experiments of deleting master and \n> making new master out of origin/master.\n> How can I change current branch in bare repositry?\n>\n> 2) I read that git rebase used 'git am' internally. How can  force git \n> am/apply to create conflicts like rebase does in form\n>\n> <<<<<<old\n> dksjfd\n> ========\n>>>>>>jfkjdfkd\n>\n> instead of *.rej files\n>\nI think the --mirror technology was made for what you are trying to do.  I \ncreated my bare repo as a mirror, but I see you don't want to recreate your \nbare repo.  However, I think you can convert yours to a mirror by modding \nyour config for that repo.  With a bare repo that is a mirror, a git fetch \nwill make the bare repo look exactly like the remote repo it is mirroring. \nThat is, the mirror will get everything that the remote has.  If the mirror \nhas extra branches that the remote does not have then the mirror will also \nkeep the extra branches as is.  However, I think if you push from the mirror \nto the remote the remote will get those extra branches so watch out for that \n(I haven't tried it yet because I don't need to do that.)\n\nYou could play around with it on a testcopy of your bare repo:\n\ncp -rp barerepo.git testmirror.git\n\nwill make a totally functional copy of your barerepo.git.  Then you could \nmod the config of testmirror.git to try and convert it to a mirror.  The \nmirror technology is on the git-clone manpage.  It doesn't explain it in \nmuch detail, but this is what I've learned from playing around with it.  You \ncan first create a bare repo mirror with git-clone to find out what the \nconfig setting are supposed to be.\n\nFor the push you can create a test copy of your remote:\n\ncp -rp remote testremote\n\nand then alter the config of testmirror.git to point to testremote.  If you \nare pushing from testremote to testmirror.git then be sure to mod \ntestremote's config to point to testmirror.git.  I don't push from my remote \nto my mirror because I use git fetch to get stuff from the remote to the \nmirror.  You shouldn't need to git push from your remote to your mirror, \neither.  However, you may have valid reasons for doing so, but I'm not sure \nwhat they would be.\n\nI am using a mirror very heavily in productional work so I know it works \n(for what I want).  I recommend you play around with it for yourself to get \na feel for it and not just go by what I say (the manpage does not explain it \nvery much).\n\nHope this helps.\n\nv/r,\nNeal \n"},{"id":"157690","messageId":"20101209165711.9cca1f28.kostix@domain007.com","threadId":"25975","inReplyTo":"60371291725083@web106.yandex.ru","subject":"Re: git fetch vs push, git am questions","fromName":"Konstantin Khomoutov","fromEmail":"flatworm@users.sourceforge.net","sentAt":"2010-12-09T13:57:11Z","receivedAt":"2010-12-09T13:57:11Z","isPatch":false,"sender":{"key":"flatworm@users.sourceforge.net","avatar":null},"body":"On Tue, 07 Dec 2010 15:31:23 +0300\nKonstantin Kivi <kkivi@yandex.ru> wrote:\n\n>>  `git pull` does exactly that: fetch + merge (which should result in\n>>  fast-forward in your case).\n> pull does not work on bare repos.\nThen the only way to update any branch after fetching I can think of\nis using `git update-ref` and the information from FETCH_HEAD.\n\n>>> I also found that there is a notions of current branch in bare\n>>> repository\n>>>  How can I change current branch in bare repositry?\n> I think I will understand things better if I get what is 'current\n> branch' for bare repository and how to change it\n>>  By re-writing the HEAD ref (this behaviour is documented in the\n>> man page of the `git clone` command, see the \"--branch\" option for\n>> instance).\n> The repository already exists, so git-clone  will not help\nI did not propose to use git-clone, I just stated which section of\nwhich manual page hints at what is considered to be the current branch\nin a bare repository when Git clones it.\n\n>>  You can use the `git symbolic-ref` to update the HEAD ref.\n> Do you mean something like \n> git symbolic-ref  master origin/master ?\nSomething like\ngit symbolic-ref HEAD refs/heads/master\n\nP.S.\nI also wonder how did you manage to get origin/master in a bare\nrepository. When I `git clone --bare` an existing Git repository,\nI get one branch named \"master\" (or whatever branch was current in the\nsource repository), and in the `git clone` manual page we see:\n\n --bare\n   Make a bare GIT repository. That is, instead of creating\n <directory> and placing the administrative files in <directory>/.git,\n make the <directory> itself the $GIT_DIR. This obviously implies the -n\n because there is nowhere to check out the working tree. Also the branch\n heads at the remote are copied directly to corresponding local branch\n heads, without mapping them to refs/remotes/origin/. When this option\n is used, neither remote-tracking branches nor the related configuration\n variables are created.\n\nWhich describes the behaviour I see. So it seems you have somehow\nbotched setup. Like you took a non-bare repository and just copied its\n\".git\" subdirectory somewhere pretending it's now a bare repo.\n"}]}