{"thread":{"id":"62042","subject":"Ask for feature on git","startedAt":"2024-09-03T08:18:28Z","lastAt":"2024-09-04T14:56:01Z","messageCount":5,"participants":["Loredana Tralli","Simon Richter","Konstantin Khomoutov"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"502002","messageId":"CAEO06G+SLu-LAe0mkR3ZbaL0MZpBm9PhntQjF-YwVPMtnuH=rQ@mail.gmail.com","threadId":"62042","inReplyTo":null,"subject":"Ask for feature on git","fromName":"Loredana Tralli","fromEmail":"loredana.tralli@gmail.com","sentAt":"2024-09-03T08:18:16Z","receivedAt":"2024-09-03T08:18:28Z","isPatch":false,"sender":{"key":"loredana.tralli@gmail.com","avatar":null},"body":"Hello,\nI'm a developer and I really use and love git. I'd really want to\nthank you for your big work\n\nI'd like to ask if exists or if it's possible to implement a feature.\nIs it possible to have a git command to find out which is the parent branch?\n\nThanks and Best Regards,\nLoredana Tralli\n"},{"id":"502035","messageId":"45a51124-7249-4678-a723-4ab9f82a5f2e@hogyros.de","threadId":"62042","inReplyTo":"CAEO06G+SLu-LAe0mkR3ZbaL0MZpBm9PhntQjF-YwVPMtnuH=rQ@mail.gmail.com","subject":"Re: Ask for feature on git","fromName":"Simon Richter","fromEmail":"simon.richter@hogyros.de","sentAt":"2024-09-03T13:33:39Z","receivedAt":"2024-09-03T13:39:53Z","isPatch":false,"sender":{"key":"simon.richter@hogyros.de","avatar":"https://gravatar.com/avatar/1192aa9fa5dd19ce258b12b044cc27111dd7cdb58d920dc2123a02a24f55b5c5?d=mp&s=160"},"body":"Hi,\n\nOn 9/3/24 17:18, Loredana Tralli wrote:\n\n> Is it possible to have a git command to find out which is the parent branch?\n\nYou can ask for the \"upstream\" branch of a given branch, using the \n\"@{upstream}\" syntax, that is documented briefly in the git-rev-parse(1) \nmanual page.\n\nThe upstream branch is automatically set if you check out a branch name \nthat only exists in a remote repository but not locally (then, a local \nbranch is created), or explicitly set with \"git branch --set-upstream-to\".\n\n    Simon\n"},{"id":"502046","messageId":"20240903170438.nhcnojx6upsxsj6d@carbon","threadId":"62042","inReplyTo":"CAEO06G+SLu-LAe0mkR3ZbaL0MZpBm9PhntQjF-YwVPMtnuH=rQ@mail.gmail.com","subject":"Re: Ask for feature on git","fromName":"Konstantin Khomoutov","fromEmail":"kostix@bswap.ru","sentAt":"2024-09-03T17:04:38Z","receivedAt":"2024-09-03T17:04:55Z","isPatch":false,"sender":{"key":"kostix@bswap.ru","avatar":null},"body":"On 9/3/24 17:18, Loredana Tralli wrote:\n\n> Is it possible to have a git command to find out which is the parent branch?\n\nPlease try to specify what you consider to be a \"parent branch\" in your\nworkflow. The problem is that there are multiple things in Git which may match\nwhat you are asking for. Even better would be to try to explain your original\nproblem you're struggling with - which made you want the feature being\ndiscussed.\n\nStill, please consider that in Git, commits do not belong to any\nbranch: each commit has metadata but that metadata do not record the name of\nthe branch (if any!) which was checked out at the time the commit was created\n(on someone's computer).\n\n"},{"id":"502113","messageId":"CAEO06GKzQTfm9z8ODCAYdHsWwgfHau0kuFA7WFkVqkPHbsm_1g@mail.gmail.com","threadId":"62042","inReplyTo":"20240903170438.nhcnojx6upsxsj6d@carbon","subject":"Re: Ask for feature on git","fromName":"Loredana Tralli","fromEmail":"loredana.tralli@gmail.com","sentAt":"2024-09-04T13:59:33Z","receivedAt":"2024-09-04T13:59:45Z","isPatch":false,"sender":{"key":"loredana.tralli@gmail.com","avatar":null},"body":"Hello,\nThank you both for your answers.\n\nI was wondering if exists a bash/cli command to find out from with\nbranch a created the new branch.\nUsually we can see it with graph or something like in this answers\nhttps://stackoverflow.com/questions/1057564/pretty-git-branch-graphs,\nnand I'd like to know if there is a command through bash to check\ndirectly \"you created branch test from branch release\".\n\nThanks in advance for your help,\nRegards\n\nLoredana Tralli\n\nIl giorno mar 3 set 2024 alle ore 19:04 Konstantin Khomoutov\n<kostix@bswap.ru> ha scritto:\n>\n> On 9/3/24 17:18, Loredana Tralli wrote:\n>\n> > Is it possible to have a git command to find out which is the parent branch?\n>\n> Please try to specify what you consider to be a \"parent branch\" in your\n> workflow. The problem is that there are multiple things in Git which may match\n> what you are asking for. Even better would be to try to explain your original\n> problem you're struggling with - which made you want the feature being\n> discussed.\n>\n> Still, please consider that in Git, commits do not belong to any\n> branch: each commit has metadata but that metadata do not record the name of\n> the branch (if any!) which was checked out at the time the commit was created\n> (on someone's computer).\n>\n"},{"id":"502137","messageId":"20240904145544.xi7rez4hvbfcx57l@carbon","threadId":"62042","inReplyTo":"CAEO06GKzQTfm9z8ODCAYdHsWwgfHau0kuFA7WFkVqkPHbsm_1g@mail.gmail.com","subject":"Re: Ask for feature on git","fromName":"Konstantin Khomoutov","fromEmail":"kostix@bswap.ru","sentAt":"2024-09-04T14:55:44Z","receivedAt":"2024-09-04T14:56:01Z","isPatch":false,"sender":{"key":"kostix@bswap.ru","avatar":null},"body":"On Wed, Sep 04, 2024 at 03:59:33PM +0200, Loredana Tralli wrote:\n\n[...]\n\n> and I'd like to know if there is a command through bash to check\n> directly \"you created branch test from branch release\".\n\nThis is quite possible: Git has a command, `git merge-base`, which can be used\nto figure out the relation between two branches you're interested in.\nIn particular, a call\n\n  $ git merge-base --fork-point test release\n\nshould print the SHA-1 name of the last commit both branches share with each\nother (before their histories have diverged) and exits with status code 0.\nOtherwise (\"test\" was not forked off \"release\") the command would print\nnothing and exit with status code 1.\n\nI would suggest to read [1] to get better understanding of what it does.\n\n 1. https://www.git-scm.com/docs/git-merge-base\n\n"}]}