1

We have a master branch and we have a release branch , when the development cycle is over a release branch is created out of master and to fix the defects during the integration phase or UAT phase, we create a branch out of release branch and and the raise a pull request to release branch.

Now when i create a branch out of release branch, the status of the branch is always shown with respect ot master, i.e. xyz branch is 40commits behind and 2 commits ahead of master. How can i make the status with respect to release branch, such that is should me xys branch is 2 commits ahead of release branch

Ambuj Jauhari
  • 1,187
  • 4
  • 26
  • 46

2 Answers2

0

You can try and change the default branch to "release" in your GitHub repo, in order to see if the branches section does display branches compared to the new default one.

You also have Compare View URL:

http://github.com/<USER>/<REPO>/compare/[<START>...]<END>

Where <USER> and <REPO> are obvious, and <START> and <END> are branch names, tag names, or commit SHA1s specifying the range of history to compare.
If <START> is omitted, the repository's default branch is assumed.

If not in github, from git shell is there any way to determice how much my branch is ahead of release branch ?

You can adapt the branch-status script from "Show git ahead and behind info for all branches, including remotes"

git for-each-ref --format="%(upstream:track)" refs/heads also display [ahead M, behind N] information, but compared to the upstream branch.

See also "git ahead/behind info between master and branch?".

Here's a trick I found to compare two branches (any two) locally and show how much commits each branch is ahead of the other::

 git rev-list --left-right --count master...test-branch

Note: Oct. 2019 (4 years later)

"Navigate to the default branch faster ":

The default branch for a repo will now appear at the top of the branches list when:

  • viewing a file,
  • changing the base branch of a pull request, and
  • comparing refs.
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Changing the default branch to release requires admin priviliges which i do not have, secondly the compare view URL gives me file differences between 2 branches. I wanted someway where when i click on branches of a repo, for each branch it should show me status if branch with respect to the branch it is created from . Is that possible ? – Ambuj Jauhari Jul 22 '15 at 08:35
  • @AmbujJauhari That leaves you with compare url: anyone can use those. – VonC Jul 22 '15 at 08:36
  • Please view the updated comment, sorry hit the enter before completing whole comment :P – Ambuj Jauhari Jul 22 '15 at 08:38
  • @AmbujJauhari I don't know of that feature. You can at least request to the owner of the repo for changing the default branch, but that will enable comparing branches only against that new default branch. Not from the branch it is created from. – VonC Jul 22 '15 at 08:39
  • If not in github, from git shell is there any way to determince how much my branch is ahead of release branch ? – Ambuj Jauhari Jul 22 '15 at 09:11
  • @AmbujJauhari I have updated the answer to address your comment. – VonC Jul 22 '15 at 09:16
0

You can compare master with your branch, or your branch with master, like this:

git diff --stat --color master..mybranch

vs.

git diff --stat --color mybranch..master

To see "colors", modify your global config:

config --global color.ui true

Personally, I like using the graphical "EGit" UI in Eclipse:

http://help.eclipse.org/luna/index.jsp?topic=%2Forg.eclipse.egit.doc%2Fhelp%2FEGit%2FUser_Guide%2FReference.html

paulsm4
  • 114,292
  • 17
  • 138
  • 190