{"thread":{"id":"18061","subject":"git-svn, and which branch am I on?","startedAt":"2009-02-28T08:50:08Z","lastAt":"2009-02-28T17:14:29Z","messageCount":4,"participants":["Daniel Pittman","Björn Steinbrink","Peter Harris","Jakub Narebski"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"106518","messageId":"87ljrr7xof.fsf@rimspace.net","threadId":"18061","inReplyTo":null,"subject":"git-svn, and which branch am I on?","fromName":"Daniel Pittman","fromEmail":"daniel@rimspace.net","sentAt":"2009-02-28T08:50:08Z","receivedAt":"2009-02-28T08:50:08Z","isPatch":false,"sender":{"key":"daniel@rimspace.net","avatar":"https://gravatar.com/avatar/67f2f02d3521b163f6b7a0dec5943d33fbc5a2a6d9702ab3fef99032e59e692f?d=mp&s=160"},"body":"G'day.\n\nI recently got asked a question about git-svn that I had no idea how to\nanswer, and which I am actually curious to know how to find out.\n\nThe general question was: in git, how do I identify where this branch\ncame from?\n\nSpecifically, this was about 'git svn', but also generally how to\nidentify this information in git.\n\nSo, with a repository branch layout like this:\n\n  master        (local)\n  testing       (local)\n  trunk         (remote)\n  v100          (remote)\n\nHow would I find out which remote branch master and trunk came from?\n\n\nTo restate that, because I am not sure if that is clear, given this\nlayout of branches:\n\n     trunk (remote)\n     |\n o---o---o---o---o  branch master\n  \\\n   \\\n    o---o---o---o branch testing\n    |\n    v100 (remote)\n\nHow can I identify that 'testing' came from the 'v100' branch, and that\nmaster came from the 'trunk' branch?\n\n\nIdeally, I would like to work this out on the command line, without\nneeding to reference gitk or another graphical tool, but even a solution\nthat used them would be fine.\n\nInitially I figured there would be some equivalent of the Mercurial\n'glog' output available, showing this; for reference the second and\nthird examples here are what I was envisaging:\nhttp://www.selenic.com/mercurial/wiki/index.cgi/GraphlogExtension\n\n(from that display I could infer where testing and master came from,\n rather than directly getting the answer, but that is just fine.)\n\n\n...and, finally, is the reason that I am finding it hard to explain this\nbecause I have an expectation of how things work that doesn't match up\nwith git?  In other words, is the question actually meaningless?\n\nRegards,\n        Daniel\n"},{"id":"106531","messageId":"20090228145416.GA6289@atjola.homenet","threadId":"18061","inReplyTo":"87ljrr7xof.fsf@rimspace.net","subject":"Re: git-svn, and which branch am I on?","fromName":"Björn Steinbrink","fromEmail":"b.steinbrink@gmx.de","sentAt":"2009-02-28T14:54:16Z","receivedAt":"2009-02-28T14:54:16Z","isPatch":false,"sender":{"key":"b.steinbrink@gmx.de","avatar":"https://avatars.githubusercontent.com/u/230962?v=4"},"body":"On 2009.02.28 19:50:08 +1100, Daniel Pittman wrote:\n> G'day.\n> \n> I recently got asked a question about git-svn that I had no idea how to\n> answer, and which I am actually curious to know how to find out.\n> \n> The general question was: in git, how do I identify where this branch\n> came from?\n\n\"git svn info\" tells you, besides other things, the URL your checked out\nbranch is based upon WRT svn. Use it with \"--url\" to show only the URL.\n\n> ...and, finally, is the reason that I am finding it hard to explain this\n> because I have an expectation of how things work that doesn't match up\n> with git?  In other words, is the question actually meaningless?\n\nIf you use git-svn, it's actually meaningful, because it controls what\nsvn rebase and svn dcommit do. For a pure git repo, it's usually not\nthat interesting.\n\nBjörn\n"},{"id":"106532","messageId":"eaa105840902280703w3dcc9b7fv9095ba874624dcca@mail.gmail.com","threadId":"18061","inReplyTo":"87ljrr7xof.fsf@rimspace.net","subject":"Re: git-svn, and which branch am I on?","fromName":"Peter Harris","fromEmail":"git@peter.is-a-geek.org","sentAt":"2009-02-28T15:03:55Z","receivedAt":"2009-02-28T15:03:55Z","isPatch":false,"sender":{"key":"git@peter.is-a-geek.org","avatar":null},"body":"On Sat, Feb 28, 2009 at 3:50 AM, Daniel Pittman wrote:\n>\n> The general question was: in git, how do I identify where this branch\n> came from?\n\n> Specifically, this was about 'git svn', but also generally how to\n> identify this information in git.\n\n> ...and, finally, is the reason that I am finding it hard to explain this\n> because I have an expectation of how things work that doesn't match up\n> with git?  In other words, is the question actually meaningless?\n\nYou've hit the nail on the head. The question is meaningless. Git\ntracks a DAG, and a branch is just that - a branch (or 'tip', if you\nwill) of the DAG.\n\nTake, for example,\n\no--o--o--o master\n \\\n  o--o--o--o feature\n      \\\n       o--o working\n\nWhich branch did 'working' come from? 'feature' or 'master'? Say I\nlater delete branch 'feature', since it was going in the wrong\ndirection. Does the answer change? What if I simply redraw the above\nso that feature and working are swapped? Does the answer change? It's\nstill the same tree.\n\nYou can, however, answer related questions.\n\n'git svn info' will tell you which branch a 'git svn dcommit' will\ncommit to, which is usually the question you actually wanted to\nanswer.\n\n'git branch -r' will tell you which remote branch your local branch is\ntracking. ie. which branch, if any, a plain 'git pull' will fetch and\nmerge from.\n\nSee also http://thread.gmane.org/gmane.comp.version-control.git/77730/focus=77823\nand surrounding thread.\n\nPeter Harris\n"},{"id":"106539","messageId":"m38wnqv5zh.fsf@localhost.localdomain","threadId":"18061","inReplyTo":"87ljrr7xof.fsf@rimspace.net","subject":"Re: git-svn, and which branch am I on?","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2009-02-28T17:14:29Z","receivedAt":"2009-02-28T17:14:29Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Daniel Pittman <daniel@rimspace.net> writes:\n\n> The general question was: in git, how do I identify where this branch\n> came from?\n\nIn general, you cannot. In specific cases, you can.\nSee below for details.\n \n> Specifically, this was about 'git svn', but also generally how to\n> identify this information in git.\n> \n> So, with a repository branch layout like this:\n> \n>   master        (local)\n>   testing       (local)\n>   trunk         (remote)\n>   v100          (remote)\n> \n> How would I find out which remote branch master and trunk came from?\n> \n> \n> To restate that, because I am not sure if that is clear, given this\n> layout of branches:\n> \n>      trunk (remote)\n>      |\n>  o---o---o---o---o  branch master\n>   \\\n>    \\\n>     o---o---o---o branch testing\n>     |\n>     v100 (remote)\n> \n> How can I identify that 'testing' came from the 'v100' branch, and that\n> master came from the 'trunk' branch?\n> \n> \n> Ideally, I would like to work this out on the command line, without\n> needing to reference gitk or another graphical tool, but even a solution\n> that used them would be fine.\n\n[...]\n> ...and, finally, is the reason that I am finding it hard to explain this\n> because I have an expectation of how things work that doesn't match up\n> with git?  In other words, is the question actually meaningless?\n\nOn the plumbing level, or on the level of graph of commits, git does\nnot store information \"where this branch came from\".  For git, from\nthe point of view of commit objects, the following two pictures are\ntotally equivalent (by design):\n\n        /-o---o      branch a\n       /\n  o---*---o---o---o  branch b\n\nand\n  \n  o---*---o---o      branch a\n       \\\n        \\-o---o---o  branch b\n\nWhat you _can_ get on this level is to find common ancestor (or common\nancestors) of branches 'a' and 'b', using \"git merge-base a b\"; this\nwould return commit marked '*'.\n\n\nHowever, when creating a branch, you can tell git that you want for\nnewly created branch to track branch you are based on (with --track)\noption.  By default saving tracking information is done when branching\noff remote-tracking branches.\n\n>From git-branch(1):\n\n  When a local branch is started off a remote branch, git sets up the\n  branch so that 'git-pull' will appropriately merge from\n  the remote branch. This behavior may be changed via the global\n  `branch.autosetupmerge` configuration flag. That setting can be\n  overridden by using the `--track` and `--no-track` options.\n\n  [...]\n\n  --track::\n      When creating a new branch, set up configuration so that 'git-pull'\n      will automatically retrieve data from the start point, which must be\n      a branch. Use this if you always pull from the same upstream branch\n      into the new branch, and if you don't want to use \"git pull\n      <repository> <refspec>\" explicitly. This behavior is the default\n      when the start point is a remote branch. Set the\n      branch.autosetupmerge configuration variable to `false` if you want\n      'git-checkout' and 'git-branch' to always behave as if '--no-track' were\n      given. Set it to `always` if you want this behavior when the\n      start-point is either a local or remote branch.\n\nAnd git-config(1)\n\n  branch.<name>.remote::\n      When in branch <name>, it tells 'git-fetch' which remote to fetch.\n      If this option is not given, 'git-fetch' defaults to remote \"origin\".\n\n  branch.<name>.merge::\n      When in branch <name>, it tells 'git-fetch' the default\n      refspec to be marked for merging in FETCH_HEAD. The value is\n      handled like the remote part of a refspec, and must match a\n      ref which is fetched from the remote given by\n      \"branch.<name>.remote\".\n      The merge information is used by 'git-pull' (which at first calls\n      'git-fetch') to lookup the default branch for merging. Without\n      this option, 'git-pull' defaults to merge the first refspec fetched.\n      Specify multiple values to get an octopus merge.\n      If you wish to setup 'git-pull' so that it merges into <name> from\n      another branch in the local repository, you can point\n      branch.<name>.merge to the desired branch, and use the special setting\n      `.` (a period) for branch.<name>.remote\n\nIn this case you can get _name_ of the branch this branch \"came from\"\nwith \"git config branch.<branchname>.merge\".\n\nHTH.\n-- \nJakub Narebski\nPoland\nShadeHawk on #git\n"}]}