dlucci
dlucci

Reputation: 808

How to find origin of a branch in git?

Say if my project contains two masters (master and master_ios) and I want to see what the origin of a feature branch is (by origin, i mean the branch the feature branch is based off), how would I accomplish this in git?

Upvotes: 60

Views: 95139

Answers (6)

Shivangi Phadke
Shivangi Phadke

Reputation: 1

git reflog

Try this command and see where your current branch checked out first. For example, you have branches A, B, and C. Your current branch is C and you are unaware of the origin. git reflog will provide you with a log of the branches moved from one head to another till the recent one. There you will have to find out from which point the branch is checked out or moved first.

e.g, (HEAD -> test/branchC, origin/HEAD, test/branchA) HEAD@{0}: checkout: moving from test/branchA to test/branchC

in this case, branch's origin is test/branchA.

Upvotes: 0

Omer Sen
Omer Sen

Reputation: 59

cat .git/config

will give you where you based your branch

Upvotes: 2

Cassette.-Earthling0
Cassette.-Earthling0

Reputation: 91

What you're looking for is the Graph available on the Repository menu :

See screenshot

2

Upvotes: 1

Daltron
Daltron

Reputation: 1856

For people who just want to see all the remote urls

git remote -v

Upvotes: 19

Lequerica Martin
Lequerica Martin

Reputation: 308

Git does not track what branch a commit was created on and does not track where a branch was branched off from. There is no information in git that you can use answer that question.

source: https://community.atlassian.com/t5/Bitbucket-questions/Knowing-from-which-branch-the-current-branch-was-created-from/qaq-p/570135

Upvotes: 14

xxxxx
xxxxx

Reputation: 1984

git remote show origin

shows remote and local branches with tracking info.

Upvotes: 55

Related Questions