{"thread":{"id":"27748","subject":"How do I get the name of the parent branch?","startedAt":"2011-07-03T16:49:19Z","lastAt":"2011-07-03T17:43:12Z","messageCount":2,"participants":["Bruce Korb","Jay Soffian"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"170793","messageId":"4E109D8F.3030402@gmail.com","threadId":"27748","inReplyTo":null,"subject":"How do I get the name of the parent branch?","fromName":"Bruce Korb","fromEmail":"bruce.korb@gmail.com","sentAt":"2011-07-03T16:49:19Z","receivedAt":"2011-07-03T16:49:19Z","isPatch":false,"sender":{"key":"bruce.korb@gmail.com","avatar":"https://gravatar.com/avatar/86d91467dc7cc8466a9d133a7b93a5d21233052017c144c9a6f6f7e5110344d0?d=mp&s=160"},"body":"Google results point to how to get to commits that have gone into\nparent branches, but fundamentally I just want to have a script\nthat constructs a diff of what has changed since the latest branch\nwithout having to do manual research to figure out the name.\n\nAs best as I can tell, you use:\n\n    git format-patch -o pdir --ignore-if-in-upstream $branch\n\nthe hard part seems to be (but ought not be) figuring out\nthe value for \"$branch\".\n"},{"id":"170794","messageId":"CAG+J_DwH8WLitQdqmgp6dLU6-Aq6Gb4nUs2y1z_UGST4Boofcw@mail.gmail.com","threadId":"27748","inReplyTo":"4E109D8F.3030402@gmail.com","subject":"Re: How do I get the name of the parent branch?","fromName":"Jay Soffian","fromEmail":"jaysoffian@gmail.com","sentAt":"2011-07-03T17:43:12Z","receivedAt":"2011-07-03T17:43:12Z","isPatch":false,"sender":{"key":"jaysoffian@gmail.com","avatar":"https://avatars.githubusercontent.com/u/155970?v=4"},"body":"On Sun, Jul 3, 2011 at 12:49 PM, Bruce Korb <bruce.korb@gmail.com> wrote:\n> Google results point to how to get to commits that have gone into\n> parent branches, but fundamentally I just want to have a script\n> that constructs a diff of what has changed since the latest branch\n> without having to do manual research to figure out the name.\n>\n> As best as I can tell, you use:\n>\n>   git format-patch -o pdir --ignore-if-in-upstream $branch\n>\n> the hard part seems to be (but ought not be) figuring out\n> the value for \"$branch\".\n\nDepending upon how you created the currently checked out branch, git\nrecorded the parent (which is usually referred to as the \"upstream\"\nbranch these days) in .git/config, and you can get this information\nthusly:\n\n  $ git rev-parse --abbrev-ref @{upstream}\n\n(But you should not be afraid to look at .git/config and see where\nthis information is recorded. Look for a section named [branch\n\"$branch].)\n\nOf course, you can use @{upstream} directly:\n\n  $ git log @{u}..  # @{u} is a synonym for @{upstream}\n  $ git diff @{u}\n\nj.\n"}]}