Question

I'd like to be able to see changes I've made to a file in a branch other than master. Is there a way to do this?

Additionally it would be really nice if I could diff between the heads of multiple branches, eg MyBranch's HEAD and master's HEAD.

Was it helpful?

Solution

All the heads (branches) and tags are listed on the project summary page (/?p=yourrepo.git;a=summary). Gitweb doesn't currently support diffing the full tree against another commit.

OTHER TIPS

You can specify branches with h=refs/heads/XXX . For example, to see branch "develop" of project testing, put the parameters /?p=teseting.git;a=log;h=refs/heads/develop

In order to see the changes introduced to README.txt on the latest commit on branch documentation:

git diff -p -1 documentation -- README.txt

(or use gitk documentation for a visual tool).

To show the difference between the head of branchA and branchB:

git diff branchA branchB

The project summary page, which lists (as stated in ellotheth's answer) all branches, slightly changes its branch order management:

With Git 2.34 (Q4 2021), tie-break branches that point at the same object in the list of branches on GitWeb to show the one pointed at by HEAD early.

See commit a45e390 (09 Jun 2021) by Greg Hurrell (wincent).
(Merged by Junio C Hamano -- gitster -- in commit 9762646, 10 Sep 2021)

gitweb: use HEAD as secondary sort key in git_get_heads_list()

Signed-off-by: Greg Hurrell

The "heads" section on the gitweb summary page shows heads in -committerdate order (ie. the most recently-modified ones at the top), tie-breaking equal-dated refs using the implicit refname sort fallback.

This recency-based ordering appears in multiple places in the UI, such as the project listing, the tags list, and even the shortlog and log views.

Given two equal-dated refs, however, sorting the HEAD ref before the non-HEAD ref provides more useful signal than merely sorting by refname.
For example, say we had "master" and "trunk" both pointing at the same commit but "trunk" was HEAD, sorting "trunk" first helps communicate its special status as the default branch that you'll check out if you clone the repo.

Add -HEAD as a secondary sort key to the git for-each-ref(man) call in git_get_heads_list() to provide the desired behavior.
The most recently committed refs will appear first, but HEAD-ness will be used as a tie-breaker.
Note that refname is the implicit fallback sort key, which means that two same-dated non-HEAD refs will continue to be sorted in lexicographical order, as they are today.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top