{"thread":{"id":"43472","subject":"Re: master and origin","startedAt":"2006-10-29T20:53:57Z","lastAt":"2006-10-29T23:19:44Z","messageCount":7,"participants":["Luben Tuikov","Paolo Ciarrocchi","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"298052","messageId":"4d8e3fd30610291253s2d8000dfx942e0fa20e0057f6@mail.gmail.com","threadId":"43472","inReplyTo":null,"subject":"master and origin","fromName":"Paolo Ciarrocchi","fromEmail":"paolo.ciarrocchi@gmail.com","sentAt":"2006-10-29T20:53:57Z","receivedAt":"2006-10-29T20:53:57Z","isPatch":false,"sender":{"key":"paolo.ciarrocchi@gmail.com","avatar":null},"body":"Hi all,\nI went trough the docs I found on the web but I still don't fully\nunderstand why if I clone a remote repository my local copy has two\nbranches, origin (that is always a exact copy of the remote\nrepository) and master which is... what? The branch supposed to be\nused for local development?\n\nI'm used to just checkout to a new branch, do my own development and\nthen diff against origin so I'm missing why I see the master branch.\n\nI'm sure I'm missing something very fundamental but I cannot figure\nout what is it :-)\n\nThanks!\n\nregards,\n-- \nPaolo\n"},{"id":"298609","messageId":"ei34qd$emn$1@sea.gmane.org","threadId":"43472","inReplyTo":"4d8e3fd30610291253s2d8000dfx942e0fa20e0057f6@mail.gmail.com","subject":"Re: master and origin","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-29T21:01:03Z","receivedAt":"2006-10-29T21:01:03Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Paolo Ciarrocchi wrote:\n\n> I went trough the docs I found on the web but I still don't fully\n> understand why if I clone a remote repository my local copy has two\n> branches, origin (that is always a exact copy of the remote\n> repository) and master which is... what? The branch supposed to be\n> used for local development?\n> \n> I'm used to just checkout to a new branch, do my own development and\n> then diff against origin so I'm missing why I see the master branch.\n> \n> I'm sure I'm missing something very fundamental but I cannot figure\n> out what is it :-)\n\nNothing very fundamental. The 'master' branch is (as name indicates)\ndefault branch on which you do your own development. The 'origin' branch\nis used to track 'master' branch in the repository you cloned from.\nIf you don't do your development on 'master', but use other branches,\nthe 'master'/'origin' is unnecessary; you could fetch 'master' into\n'master'...\n\nBy the way, if you clone with --use-separate-remote you would get\nseparate namespace for tracking branches; additionally they would\nbe treated read-only (can't commit to).\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n\n"},{"id":"295745","messageId":"200610292219.21823.jnareb@gmail.com","threadId":"43472","inReplyTo":"4d8e3fd30610291307v24f5aab8l3f447a1bfdf86ab4@mail.gmail.com","subject":"Re: master and origin","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-29T21:19:21Z","receivedAt":"2006-10-29T21:19:21Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Paolo Ciarrocchi wrote:\n> On 10/29/06, Jakub Narebski <jnareb@gmail.com> wrote:\n>> Paolo Ciarrocchi wrote:\n>>\n>>> I went trough the docs I found on the web but I still don't fully\n>>> understand why if I clone a remote repository my local copy has two\n>>> branches, origin (that is always a exact copy of the remote\n>>> repository) and master which is... what? The branch supposed to be\n>>> used for local development?\n>>>\n>>> I'm used to just checkout to a new branch, do my own development and\n>>> then diff against origin so I'm missing why I see the master branch.\n[...]\n>> If you don't do your development on 'master', but use other branches,\n>> the 'master'/'origin' is unnecessary; you could fetch 'master' into\n>> 'master'...\n>>\n>> By the way, if you clone with --use-separate-remote you would get\n>> separate namespace for tracking branches; additionally they would\n>> be treated read-only (can't commit to).\n> \n> There is still one thing I don't understand, if I pull the git or\n> kernel repository all the local branches are updated according to the\n> remote branches, right? If I'm hacking on master what will happen to\n> my local changes?\n\nWith the default setup (git clone without --use-separate-remote), then\nall local branches are updated according to remote branches... with the\nexception of remote 'master' branch which updates local 'origin' branch.\npull = fetch + merge, so if you pull when you are on your local 'master'\nbranch (and 'master' branch is first in the .git/remotes/origin file I think)\nyou would fetch remote 'master' into local 'origin' and merge what you\nhave in 'origin' into your 'master' (or merge remote 'master' into\nyour local 'master' if you want to think like that).\n\nIf you have uncommitted changes git would probably refuse the merge.\nIf you made changes to one of the tracking branches (e.g. 'next' or\n'origin'), git would refuse to fetch into this branch (unless forced).\n\nHTH\n-- \nJakub Narebski\n"},{"id":"295368","messageId":"4d8e3fd30610291329n7fe59873r87cbee9ccbd4b720@mail.gmail.com","threadId":"43472","inReplyTo":"200610292219.21823.jnareb@gmail.com","subject":"Re: master and origin","fromName":"Paolo Ciarrocchi","fromEmail":"paolo.ciarrocchi@gmail.com","sentAt":"2006-10-29T21:29:32Z","receivedAt":"2006-10-29T21:29:32Z","isPatch":false,"sender":{"key":"paolo.ciarrocchi@gmail.com","avatar":null},"body":"On 10/29/06, Jakub Narebski <jnareb@gmail.com> wrote:\n> > There is still one thing I don't understand, if I pull the git or\n> > kernel repository all the local branches are updated according to the\n> > remote branches, right? If I'm hacking on master what will happen to\n> > my local changes?\n>\n> With the default setup (git clone without --use-separate-remote), then\n> all local branches are updated according to remote branches... with the\n> exception of remote 'master' branch which updates local 'origin' branch.\n\nOK, I see.\n\n> pull = fetch + merge, so if you pull when you are on your local 'master'\n> branch (and 'master' branch is first in the .git/remotes/origin file I think)\n> you would fetch remote 'master' into local 'origin' and merge what you\n> have in 'origin' into your 'master' (or merge remote 'master' into\n> your local 'master' if you want to think like that).\n\nSo in this case, there is a difference between doing my local\ndevelopment under master or myownlocalbranch. Right?\nI mean, if I do my own development under master and I pull, the master\nbranch will include origin and my local changes. Corret?\nWhile if I work in my local branch the datas are not modified with a\npull, because pull will update only the local copy of the remote\nbranch. Correct?\n\n> If you have uncommitted changes git would probably refuse the merge.\n> If you made changes to one of the tracking branches (e.g. 'next' or\n> 'origin'), git would refuse to fetch into this branch (unless forced).\n>\n> HTH\n\nIt does, a lot!\n\nCiao,\n-- \nPaolo\nhttp://docs.google.com/View?docid=dhbdhs7d_4hsxqc8\n\nNon credo nelle otto del mattino. Però esistono. Le otto del mattino\nsono l'incontrovertibile prova della presenza del male nel mondo.\n"},{"id":"296801","messageId":"200610292240.57443.jnareb@gmail.com","threadId":"43472","inReplyTo":"4d8e3fd30610291329n7fe59873r87cbee9ccbd4b720@mail.gmail.com","subject":"Re: master and origin","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-10-29T21:40:57Z","receivedAt":"2006-10-29T21:40:57Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Paolo Ciarrocchi wrote:\n> On 10/29/06, Jakub Narebski <jnareb@gmail.com> wrote:\n[...]\n>> pull = fetch + merge, so if you pull when you are on your local 'master'\n>> branch (and 'master' branch is first in the .git/remotes/origin file I think)\n>> you would fetch remote 'master' into local 'origin' and merge what you\n>> have in 'origin' into your 'master' (or merge remote 'master' into\n>> your local 'master' if you want to think like that).\n> \n> So in this case, there is a difference between doing my local\n> development under master or myownlocalbranch. Right?\n> I mean, if I do my own development under master and I pull, the master\n> branch will include origin and my local changes. Corret?\n> While if I work in my local branch the datas are not modified with a\n> pull, because pull will update only the local copy of the remote\n> branch. Correct?\n\nTo be more exact (sorry for the confusion) \"git pull\" means first do\nthe \"git fetch\", i.e. update local 'tracking' branches with the contents\nof remote branches. For ordinary clone this means:\n\n    remote (origin)  | local\n   ------------------+------------------\n    master           | origin\n    next             | next\n    ...              | ...\n\nFor --use-separate-remote this means\n\n   remote (origin)   | local\n  -------------------+-------------------\n   master            | refs/remotes/origin/master\n   next              | refs/remotes/origin/next\n   ...               | ...\n\nThen it does \"merge\". It takes the remote branch from first Pull: line in\nremotes/origin file, or first in remote.origin.fetch configuration variable,\nand merges it with _current_ branch.\n\nSo if you always work on local branches, and newer want to merge\nautomatically, you probably should use \"git fetch\" for fetching changes.\n\n\nWhat is not obvious (and is PITA for first-timers) that to merge\nsome <sidebranch> into your <branch>, it is simplest to first switch\nto <branch> using\n  git checkout <branch>\nand then merge <sidebranch> using\n  git pull . <sidebranch>\n(where '.' means local repository).\n\nHTH\n-- \nJakub Narebski\n"},{"id":"294988","messageId":"137435.85891.qm@web31809.mail.mud.yahoo.com","threadId":"43472","inReplyTo":"4d8e3fd30610291253s2d8000dfx942e0fa20e0057f6@mail.gmail.com","subject":"Re: master and origin","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-29T22:58:55Z","receivedAt":"2006-10-29T22:58:55Z","isPatch":false,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> wrote:\n> Hi all,\n> I went trough the docs I found on the web but I still don't fully\n> understand why if I clone a remote repository my local copy has two\n> branches, origin (that is always a exact copy of the remote\n> repository) and master which is... what? The branch supposed to be\n> used for local development?\n> \n> I'm used to just checkout to a new branch, do my own development and\n> then diff against origin so I'm missing why I see the master branch.\n> \n> I'm sure I'm missing something very fundamental but I cannot figure\n> out what is it :-)\n\nRead the documentation of git-fetch and especially the second\n\"Note\" therein.\n\n   Luben\n"},{"id":"295820","messageId":"118164.43697.qm@web31807.mail.mud.yahoo.com","threadId":"43472","inReplyTo":"4d8e3fd30610291329n7fe59873r87cbee9ccbd4b720@mail.gmail.com","subject":"Re: master and origin","fromName":"Luben Tuikov","fromEmail":"ltuikov@yahoo.com","sentAt":"2006-10-29T23:19:44Z","receivedAt":"2006-10-29T23:19:44Z","isPatch":false,"sender":{"key":"ltuikov@yahoo.com","avatar":null},"body":"--- Paolo Ciarrocchi <paolo.ciarrocchi@gmail.com> wrote:\n> \n> So in this case, there is a difference between doing my local\n> development under master or myownlocalbranch. Right?\n> I mean, if I do my own development under master and I pull, the master\n> branch will include origin and my local changes. Corret?\n> While if I work in my local branch the datas are not modified with a\n> pull, because pull will update only the local copy of the remote\n> branch. Correct?\n\nFollowing GIT's working flow isn't that much different than\nother SCM's workflow.\n\nLeave master and origin branches alone.  Imagine they are your\nlocal copy of that imaginary \"root\" repo.\n\nIf you want to do development, create your own branch off of\nmaster at some point, say HEAD, using git-branch, call it my-branch.\n\nThen do your development in my-branch, occasionally pulling from\nmaster, all the while you update master on a regular basis\nfrom the remote repo.  That pull into my-branch would schedule\nthe merge for you and if it cannot auto-merge, it will leave it\nup to you do _resolve_ and then commit.  Eventually\nyou get into the habit of following the same commands in the\nsame steps.\n\nNote the key words here: pull, merge, commit.  Pull and merge is\nis done by git-pull, and if there's things to resolve you do that\nmanually, in most simplistic ways.\n\nIf you're coming from another SCM, picking up git is a snap.\nI think the only \"hurdle\" coming from another SCM especially\ncentralized is the decentralized nature of git.\n\nReading git-fetch, git-pull documentation very carefully\nshould clear things up.\n\n     Luben\n"}]}