找出用于创建分支的存储库

时间:2016-05-09 22:19:58

标签: git atlassian-sourcetree

有没有办法找出在Sourcetree或GIT中用于创建分支的分支?

2 个答案:

答案 0 :(得分:0)

git remote -v为您提供远程回购。

答案 1 :(得分:0)

如果你想找出你所从的父分支,你可以看一下this other thread,似乎有不同的答案。

我在Windows上,所以我尝试了这个,并且使用PowerShell对我有用:

git show-branch -a | where-object { $_.Contains('*') -eq $true} | Where-object{$_.Contains($branchName) -ne $true } | select -first 1 | % {$_ -replace('.*\[(.*)\].*','$1')} | % { $_ -replace('[\^~].*','') }

确保将$ branchName替换为当前分支名称,或者在运行命令之前预先设置它。

如果您使用的是bash,那么还有很多答案可以使用grepsed以及其他bash实用程序来解析git show-branch {1}}命令输出。