* git-diff across branches?
@ 2008-01-08 8:44 Gonzalo Garramuño
2008-01-08 8:57 ` Jeff King
0 siblings, 1 reply; 3+ messages in thread
From: Gonzalo Garramuño @ 2008-01-08 8:44 UTC (permalink / raw)
To: git
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)
--
Gonzalo Garramuño
ggarra@advancedsl.com.ar
AMD4400 - ASUS48N-E
GeForce7300GT
Xubuntu Gutsy
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-diff across branches?
2008-01-08 8:44 git-diff across branches? Gonzalo Garramuño
@ 2008-01-08 8:57 ` Jeff King
2008-01-08 10:01 ` Jakub Narebski
0 siblings, 1 reply; 3+ messages in thread
From: Jeff King @ 2008-01-08 8:57 UTC (permalink / raw)
To: Gonzalo Garramuño; +Cc: git
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
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: git-diff across branches?
2008-01-08 8:57 ` Jeff King
@ 2008-01-08 10:01 ` Jakub Narebski
0 siblings, 0 replies; 3+ messages in thread
From: Jakub Narebski @ 2008-01-08 10:01 UTC (permalink / raw)
To: Jeff King; +Cc: Gonzalo Garramuño, git
Jeff King <peff@peff.net> writes:
> 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
Canonically it is
# git diff test1 test2 -- file.cpp
but you can also use (for example if file was renamed)
# git diff test1:file.cpp 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:
[cut]
Not necessary. If those two repositories are on the same local
filesystem, you can use trick from GitTips:
http://git.or.cz/gitwiki/GitTips#head-9f79516c05f0c1b51945b848adb3dd1c5a2bf016
(assuming we are in test1, and ../test2 is relative path to test2)
# GIT_ALTERNATE_OBJECT_DIRECTORIES=../test2/.git/objects git diff-tree \
$(GIT_DIR=../test2/.git git rev-parse --verify HEAD) HEAD
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-01-08 10:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-01-08 8:44 git-diff across branches? Gonzalo Garramuño
2008-01-08 8:57 ` Jeff King
2008-01-08 10:01 ` Jakub Narebski
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).