git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: "Gonzalo Garramuño" <ggarra@advancedsl.com.ar>
Cc: git@vger.kernel.org
Subject: Re: git-diff across branches?
Date: Tue, 8 Jan 2008 03:57:06 -0500	[thread overview]
Message-ID: <20080108085705.GA4222@sigill.intra.peff.net> (raw)
In-Reply-To: <478337DE.7@advancedsl.com.ar>

On Tue, Jan 08, 2008 at 05:44:14AM -0300, Gonzalo Garramuño wrote:

> I was wondering if there was a way to make a git-diff across (local)  
> branches.
>
> Something like:
>
> $ git-diff --branch test1 HEAD --branch test2 HEAD  file.cpp
> (would show a diff for file.cpp between test1 HEAD and test2 HEAD)

I think you are mistaken about how HEAD works; it is a pointer to a
particular branch. So there is no "HEAD" for test1; there is simply
test1, and from time to time your repository's HEAD points to test1.

However, that makes things easier. You can simply do this:

  git-diff test1 test2 file.cpp

Unless you mean that you have two separate repositories, test1 and
test2. In which case each _does_ have its own HEAD, and you will have to
fetch from one repo into the other to get your answer:

  # go into one of the repos
  cd test1
  # fetch the 'master' ref from the other repo and store it in this repo
  # using the name 'test2'
  git fetch ../test2 master:test2
  # now we can diff between them
  git diff HEAD test2 file.cpp

-Peff

  reply	other threads:[~2008-01-08  8:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-08  8:44 git-diff across branches? Gonzalo Garramuño
2008-01-08  8:57 ` Jeff King [this message]
2008-01-08 10:01   ` Jakub Narebski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080108085705.GA4222@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=ggarra@advancedsl.com.ar \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).