Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I tell which remote "parent" branch my branch is based on?

I have a scenario in which there a several remote tracking branches within my local repository that I must sync up to. Our workflow model is:

  • make a branch locally, based off of the desired remote tracking branch
  • make our changes
  • build/test/fix
  • commit
  • push back to the remote server

I've noticed that "git status" doesn't show me what branch my local branch is based on unless something has changed; i.e. uncommitted local changes or a recent fetch puts my local branch behind the times. Is there some way of knowing what branch my local branch is based on without having to change things? Something like, "git status -showparentbranch" or some other command that would show this. Occasionally I run into this need but don't know yet how to satisfy it.

like image 601
Andrew Falanga Avatar asked Jun 23 '11 15:06

Andrew Falanga


People also ask

How can I tell which remote branch I am tracking?

There is a command that gives you about all tracking branches. And to know about the pull and push configuration per branch you can use the command git remote show origin. and you can use -sb option for seeing the upstream. Hope this information will help you to find which branch is tracking.

Does git branch show remote branches?

To view your remote branches, simply pass the -r flag to the git branch command. You can inspect remote branches with the usual git checkout and git log commands. If you approve the changes a remote branch contains, you can merge it into a local branch with a normal git merge .

What is a parent branch?

Parent Branch means the main branch from where the Additional Profile is trading.

How do you know from which branch a branch was created bitbucket?

First, you can use the "git log --graph --all" option (potentially with "--pretty=format:...") and visually trace back a branch to see what commit it branched from (also referred to as an Ancestor Commit) and then (assuming the history is easy enough to read/understand) trace back up to find out which branch that ...


2 Answers

try this:

git log --graph --decorate 
like image 169
elrrrrrrr Avatar answered Sep 23 '22 21:09

elrrrrrrr


Git does not track what branches a commit was put through. There is no way to tell. If the commits happened on your repo, then you can inspect the reflog, but that's about it. Take a look at the explanation of the DAG in the Pro Git book - also read up on reflog in there.

You can also visualize history better with gitk --all or git log --graph --decorate

Hope this helps.

like image 30
Adam Dymitruk Avatar answered Sep 19 '22 21:09

Adam Dymitruk