Is there a way to find out which branch was used to create a branch from in Sourcetree or GIT?
Asked
Active
Viewed 44 times
0
-
Your comment on Yasser's answer seems to be different than your question. Can you add some additional clarification about what you're trying to do? – BJ Myers May 10 '16 at 18:19
-
@BJ Myers I created a branch called BranchB from a branch called BranchA. I did this a while ago and I have forgotten which branch I used to create BranchB. My question is how do I find out the name of BranchA? – Clinton Green May 11 '16 at 04:18
2 Answers
0
git remote -v
gives you the remote repo.

yelsayed
- 5,236
- 3
- 27
- 38
-
Hi @Yasser Elsayed my remote repo name is the same as my local branch. I'm trying to find out what branch I used to create this branch. – Clinton Green May 09 '16 at 22:44
-
@ClintonGreen I'm not sure I understand what you're trying to do. A repo is not the same as a branch. `git remote -v` gives you the address of the remote repo. If you want to get the name of the remote branch you're tracking, `git status` shows you that, says something like `Your branch is up-to-date with 'origin/branch_name'.` – yelsayed May 10 '16 at 00:23
-
Hi I think I used the wrong terminology. I'm looking for the name of the branch used to create the current branch I am working in. Thanks – Clinton Green May 11 '16 at 04:19
-
-
0
If you want to find out the parent branch that you stemmed from, you can take a look at this other thread, seems to have all the different answers for this.
I'm on Windows, so I tried this and it worked for me using PowerShell:
git show-branch -a | where-object { $_.Contains('*') -eq $true} | Where-object{$_.Contains($branchName) -ne $true } | select -first 1 | % {$_ -replace('.*\[(.*)\].*','$1')} | % { $_ -replace('[\^~].*','') }
Make sure to replace $branchName with whatever the current branch name is, or set it in advance before running the command.
If you're on bash
there are also lots of answers in there that use grep
and sed
and other bash
utilities to do this same parsing of the git show-branch
command output.