* Ask for feature on git
@ 2024-09-03 8:18 Loredana Tralli
2024-09-03 13:33 ` Simon Richter
2024-09-03 17:04 ` Konstantin Khomoutov
0 siblings, 2 replies; 5+ messages in thread
From: Loredana Tralli @ 2024-09-03 8:18 UTC (permalink / raw)
To: git
Hello,
I'm a developer and I really use and love git. I'd really want to
thank you for your big work
I'd like to ask if exists or if it's possible to implement a feature.
Is it possible to have a git command to find out which is the parent branch?
Thanks and Best Regards,
Loredana Tralli
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ask for feature on git
2024-09-03 8:18 Ask for feature on git Loredana Tralli
@ 2024-09-03 13:33 ` Simon Richter
2024-09-03 17:04 ` Konstantin Khomoutov
1 sibling, 0 replies; 5+ messages in thread
From: Simon Richter @ 2024-09-03 13:33 UTC (permalink / raw)
To: Loredana Tralli, git
Hi,
On 9/3/24 17:18, Loredana Tralli wrote:
> Is it possible to have a git command to find out which is the parent branch?
You can ask for the "upstream" branch of a given branch, using the
"@{upstream}" syntax, that is documented briefly in the git-rev-parse(1)
manual page.
The upstream branch is automatically set if you check out a branch name
that only exists in a remote repository but not locally (then, a local
branch is created), or explicitly set with "git branch --set-upstream-to".
Simon
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ask for feature on git
2024-09-03 8:18 Ask for feature on git Loredana Tralli
2024-09-03 13:33 ` Simon Richter
@ 2024-09-03 17:04 ` Konstantin Khomoutov
2024-09-04 13:59 ` Loredana Tralli
1 sibling, 1 reply; 5+ messages in thread
From: Konstantin Khomoutov @ 2024-09-03 17:04 UTC (permalink / raw)
To: Loredana Tralli; +Cc: git
On 9/3/24 17:18, Loredana Tralli wrote:
> Is it possible to have a git command to find out which is the parent branch?
Please try to specify what you consider to be a "parent branch" in your
workflow. The problem is that there are multiple things in Git which may match
what you are asking for. Even better would be to try to explain your original
problem you're struggling with - which made you want the feature being
discussed.
Still, please consider that in Git, commits do not belong to any
branch: each commit has metadata but that metadata do not record the name of
the branch (if any!) which was checked out at the time the commit was created
(on someone's computer).
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ask for feature on git
2024-09-03 17:04 ` Konstantin Khomoutov
@ 2024-09-04 13:59 ` Loredana Tralli
2024-09-04 14:55 ` Konstantin Khomoutov
0 siblings, 1 reply; 5+ messages in thread
From: Loredana Tralli @ 2024-09-04 13:59 UTC (permalink / raw)
To: Loredana Tralli, Simon.Richter, kostix; +Cc: git
Hello,
Thank you both for your answers.
I was wondering if exists a bash/cli command to find out from with
branch a created the new branch.
Usually we can see it with graph or something like in this answers
https://stackoverflow.com/questions/1057564/pretty-git-branch-graphs,
nand I'd like to know if there is a command through bash to check
directly "you created branch test from branch release".
Thanks in advance for your help,
Regards
Loredana Tralli
Il giorno mar 3 set 2024 alle ore 19:04 Konstantin Khomoutov
<kostix@bswap.ru> ha scritto:
>
> On 9/3/24 17:18, Loredana Tralli wrote:
>
> > Is it possible to have a git command to find out which is the parent branch?
>
> Please try to specify what you consider to be a "parent branch" in your
> workflow. The problem is that there are multiple things in Git which may match
> what you are asking for. Even better would be to try to explain your original
> problem you're struggling with - which made you want the feature being
> discussed.
>
> Still, please consider that in Git, commits do not belong to any
> branch: each commit has metadata but that metadata do not record the name of
> the branch (if any!) which was checked out at the time the commit was created
> (on someone's computer).
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Ask for feature on git
2024-09-04 13:59 ` Loredana Tralli
@ 2024-09-04 14:55 ` Konstantin Khomoutov
0 siblings, 0 replies; 5+ messages in thread
From: Konstantin Khomoutov @ 2024-09-04 14:55 UTC (permalink / raw)
To: Loredana Tralli; +Cc: Simon.Richter, kostix, git
On Wed, Sep 04, 2024 at 03:59:33PM +0200, Loredana Tralli wrote:
[...]
> and I'd like to know if there is a command through bash to check
> directly "you created branch test from branch release".
This is quite possible: Git has a command, `git merge-base`, which can be used
to figure out the relation between two branches you're interested in.
In particular, a call
$ git merge-base --fork-point test release
should print the SHA-1 name of the last commit both branches share with each
other (before their histories have diverged) and exits with status code 0.
Otherwise ("test" was not forked off "release") the command would print
nothing and exit with status code 1.
I would suggest to read [1] to get better understanding of what it does.
1. https://www.git-scm.com/docs/git-merge-base
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-09-04 14:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-03 8:18 Ask for feature on git Loredana Tralli
2024-09-03 13:33 ` Simon Richter
2024-09-03 17:04 ` Konstantin Khomoutov
2024-09-04 13:59 ` Loredana Tralli
2024-09-04 14:55 ` Konstantin Khomoutov
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).