{"thread":{"id":"27702","subject":"git push in a git-init without --bare option?","startedAt":"2011-06-26T10:42:28Z","lastAt":"2011-06-26T22:30:17Z","messageCount":5,"participants":["Pedro Sa Costa","Elia Pinto","Matthieu Moy","Christof Krüger"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"170546","messageId":"201106261142.28142.psdc1978@gmail.com","threadId":"27702","inReplyTo":null,"subject":"git push in a git-init without --bare option?","fromName":"Pedro Sa Costa","fromEmail":"psdc1978@gmail.com","sentAt":"2011-06-26T10:42:28Z","receivedAt":"2011-06-26T10:42:28Z","isPatch":false,"sender":{"key":"psdc1978@gmail.com","avatar":null},"body":"Hi,\n\nI'm newbie in git and I'm trying to understand how git works.\n\n- I see that in git, I can't do git-push to a repository that wasn't created \nwith git-init --bare. Why?\n\n- But doing git-pull and git-checkout to the same repository is possible. I'm \nreally confused. Any help?\n\n-- \nBest regards,\n\n-----------------------\n"},{"id":"170548","messageId":"BANLkTikWz81GM5mouzOHwi4eAGvg1BG8XQ@mail.gmail.com","threadId":"27702","inReplyTo":"201106261142.28142.psdc1978@gmail.com","subject":"Re: git push in a git-init without --bare option?","fromName":"Elia Pinto","fromEmail":"gitter.spiros@gmail.com","sentAt":"2011-06-26T11:35:56Z","receivedAt":"2011-06-26T11:35:56Z","isPatch":false,"sender":{"key":"gitter.spiros@gmail.com","avatar":"https://avatars.githubusercontent.com/u/158490?v=4"},"body":"Git doesn't keep track on the remote repo if someone change the\ncheckout file. So it was always a bad habit to push to a not bare\nrepo, you could lost commit. From 1.7 git don't permit, by default, to\npush to a non bare repo. Best regards\n\n2011/6/26, Pedro Sa Costa <psdc1978@gmail.com>:\n> Hi,\n>\n> I'm newbie in git and I'm trying to understand how git works.\n>\n> - I see that in git, I can't do git-push to a repository that wasn't created\n> with git-init --bare. Why?\n>\n> - But doing git-pull and git-checkout to the same repository is possible.\n> I'm\n> really confused. Any help?\n>\n> --\n> Best regards,\n>\n> -----------------------\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-- \nInviato dal mio dispositivo mobile\n"},{"id":"170550","messageId":"vpqliwoa24m.fsf@bauges.imag.fr","threadId":"27702","inReplyTo":"201106261142.28142.psdc1978@gmail.com","subject":"Re: git push in a git-init without --bare option?","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2011-06-26T18:17:29Z","receivedAt":"2011-06-26T18:17:29Z","isPatch":false,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Pedro Sa Costa <psdc1978@gmail.com> writes:\n\n> - I see that in git, I can't do git-push to a repository that wasn't created \n> with git-init --bare. Why?\n>\n> - But doing git-pull and git-checkout to the same repository is possible. I'm \n> really confused. Any help?\n\ngit pull involves a merge, and merge may involve conflicts, and\nconflicts involve a user fixing them ... So, doing a \"git pull\" to merge\nin remote changes is OK, but a \"git push\" cannot merge changes remotely,\nhence the asymetry.\n\nGit could just send the commits, without updating the working tree, but\nthat would be terrible for the user. Let's say the user has no local\nchange before the push. His checkout points to the tip of a branch\n(information stored in HEAD), so the tree matches the old HEAD. Updating\nthe branch means changing the commit pointed to by HEAD, hence after a\npush, the tree does not match the HEAD anymore (which means the next\ncommit will seem to revert the pushed history). This is to prevent this\nsituation that Git refuses to push to non-bare repos.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"},{"id":"170560","messageId":"201106262221.33294.psdc1978@gmail.com","threadId":"27702","inReplyTo":"vpqliwoa24m.fsf@bauges.imag.fr","subject":"Re: git push in a git-init without --bare option?","fromName":"Pedro Sa Costa","fromEmail":"psdc1978@gmail.com","sentAt":"2011-06-26T21:21:33Z","receivedAt":"2011-06-26T21:21:33Z","isPatch":false,"sender":{"key":"psdc1978@gmail.com","avatar":null},"body":"So this means that eveytime that I want a repository to be shared by several \npersons, the repository must always be bare?\n\n\n\n> Pedro Sa Costa <psdc1978@gmail.com> writes:\n> > - I see that in git, I can't do git-push to a repository that wasn't\n> > created with git-init --bare. Why?\n> > \n> > - But doing git-pull and git-checkout to the same repository is possible.\n> > I'm really confused. Any help?\n> \n> git pull involves a merge, and merge may involve conflicts, and\n> conflicts involve a user fixing them ... So, doing a \"git pull\" to merge\n> in remote changes is OK, but a \"git push\" cannot merge changes remotely,\n> hence the asymetry.\n> \n> Git could just send the commits, without updating the working tree, but\n> that would be terrible for the user. Let's say the user has no local\n> change before the push. His checkout points to the tip of a branch\n> (information stored in HEAD), so the tree matches the old HEAD. Updating\n> the branch means changing the commit pointed to by HEAD, hence after a\n> push, the tree does not match the HEAD anymore (which means the next\n> commit will seem to revert the pushed history). This is to prevent this\n> situation that Git refuses to push to non-bare repos.\n-- \nBest regards,\n\n-----------------------\n"},{"id":"170562","messageId":"1309127417.11860.142.camel@oxylap","threadId":"27702","inReplyTo":"201106262221.33294.psdc1978@gmail.com","subject":"Re: git push in a git-init without --bare option?","fromName":"Christof Krüger","fromEmail":"mail@christof-krueger.de","sentAt":"2011-06-26T22:30:17Z","receivedAt":"2011-06-26T22:30:17Z","isPatch":false,"sender":{"key":"mail@christof-krueger.de","avatar":null},"body":"On So, 2011-06-26 at 22:21 +0100, Pedro Sa Costa wrote:\n> So this means that eveytime that I want a repository to be shared by\n> several \n> persons, the repository must always be bare?\n\nShort answer: no.\n\nLong answer: Not necessarily, it depends on your workflow.\n\nYou could have a central \"official\" repository on a server that is\naccessible by all members of your team. This is how centralized\nversion-control systems like Subversion work. You can imitate this with\ngit, but with git it's just convention, not a technical necessity. This\ncentral repository would then be bare, as nobody will work on it\ndirectly. If connectivity between developers is an issue (e.g. because\nof firewalls or NAT), this might be the preferred model in some cases.\nYou can also use a service like github.com for example.\n\nBut you could also use it the distributed way. Then you should\nunderstand and respect the asymmetry between push and pull. Every\ndeveloper on a team can have a local (non-bare) repository he works on.\nAs it is his private repository, all you can say is \"hey buddy, I've got\na shiny new feature ready. Pull branch 'foobar' from my private\nrepository\". He can then decide to pull and merge it with his code if he\nwishes.\n\nThe above doesn't work if you'd allowed everyone to push around stuff to\nother developers without their consent. You would lose control over your\nown private repository and your working-copy would never be up-to-date\nwith what is the HEAD of your repo.\n\nOf course, you can have a topology that is far more complex than what I\noutlined above, combining bare and non-bare repositories at once and\nhaving multiple repositories per developer, but I hope that the basic\nidea became clear.\n\nRegards,\n  Chris\n"}]}