tags:

views:

285

answers:

3

Hi All, I have forked git repository of one project on github and made my own changes to it. I wanted to get diff between my repository and original repository that I've forked. Can someone tell me git command to get that diff ? I need to submit the diff for review.

Original repository:
git://github.com/apache/hive.git
My repository:
[email protected]:prafullat/hive.git

Here are details from my .git/config

[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = [email protected]:prafullat/hive.git
[remote "mirror"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = git://github.com/apache/hive.git

I tried looking at already posted questions regarding the same topic and could not get it to work. Any help would be highly appreciated.

A: 
git diff remotes/origin remotes/mirror

Something along that should do the trick.

poke
It gives this error.git diff remotes/origin remotes/mirrorfatal: ambiguous argument 'remotes/origin': unknown revision or path not in the working tree.Use '--' to separate paths from revisions
Prafulla
A: 

Getting commit sha1 manually and using them in diff solved the problem!

[prafulla@prafulla-laptop .git] $cd refs/remotes/
[prafulla@prafulla-laptop remotes] $cat origin/trunk
1c4fa827f4fad2aad67a4fa5b57d88afe51d1559
[prafulla@prafulla-laptop remotes] $cat mirror/trunk 
14f5fb7cba7bef466727a5b721c7c202e80e5dfd
[prafulla@prafulla-laptop remotes] $git diff 14f5fb7cba7bef466727a5b721c7c202e80e5dfd 1c4fa827f4fad2aad67a4fa5b57d88afe51d1559
.......
.... diff follows!.......

Prafulla
+3  A: 

You need to fetch the latest of both remote repositories and compare the main branches to each other. It looks like the main branch is the 'trunk' branch, so you can see what commits are unique to your project (and not in the trunk branch of the 'mirror' project) like this:

$ git log --oneline origin/trunk ^mirror/trunk
1c4fa82 1. Modified the flag name for gb_to_idx rewrite to    hive.ql.rewrite.gb_to_idx    So
638be54 Merge branch 'trunk' of [email protected]:prafullat/hive into trunk
72c8220 HIVE-1383. Allow HBase WAL to be disabled (John Sichi via Ning Zhang)
a372259 Checking in commented meta-data methods in GbToCompactSumIdxRewrite. It has to be unc
33c1fb1 Fixing some files due to wrong application of patch. Build now compiles !
5942728 Reverting files which were patched twice in last checkin.
5efda04 Adding inital rewrite changes. This patch adds basic query rewrite support to Hive. I
3fce190 Merge branch 'trunk' of git://github.com/apache/hive into trunk
b3f9ff2 Checking in commented meta-data methods in GbToCompactSumIdxRewrite. It has to be unc
d89deb9 Fixing some files due to wrong application of patch. Build now compiles !
11db7da Reverting files which were patched twice in last checkin.
88fee30 Adding inital rewrite changes.
ba7703f Some part of last check-in got missed.
2c5c5ae Checking initial changes for Hive indexing from He Yongqiang (Hive-417) Here is descr

Or you can remove the --oneline to see the full commit messages. It looks like they're all yours. You can also add a --no-merges if you don't want to see those merge commits.

Next, you can get the actual diff by running this:

$ git diff --stat mirror/trunk...origin/trunk
 README.txt                                         |    4 +-
 build.xml                                          |    1 +
 .../java/org/apache/hadoop/hive/conf/HiveConf.java |    1 +
 ivy/ivysettings.xml                                |    4 +-
 metastore/if/hive_metastore.thrift                 |   12 +-
 .../apache/hadoop/hive/metastore/api/Index.java    |   15 +-
 .../hive/metastore/api/ThriftHiveMetastore.java    |  671 +++++++++++++++++++-
 metastore/src/gen-php/hive_metastore_types.php     |   30 +-
 .../hadoop/hive/metastore/HiveMetaStore.java       |  155 ++++-
 .../hadoop/hive/metastore/HiveMetaStoreClient.java |    9 +-
 .../hadoop/hive/metastore/IMetaStoreClient.java    |   14 +
 .../hadoop/hive/metastore/MetaStoreUtils.java      |   31 +
(bunch more lines)
 ql/src/test/queries/clientpositive/index_compact.q |   13 +
 .../test/queries/clientpositive/index_projection.q |   13 +
 ql/src/test/queries/clientpositive/index_summary.q |   13 +
 .../queries/clientpositive/ql_rewrite_gbtoidx.q    |    9 +
 .../results/clientpositive/index_compact.q.out     |   70 ++
 .../clientpositive/ql_rewrite_gbtoidx.q.out        |  211 ++++++
 .../primitive/PrimitiveObjectInspectorUtils.java   |   29 +-
 57 files changed, 4000 insertions(+), 131 deletions(-)

If you remove the --stat, you'll get the actual diff. The ... in between the mirror/trunk and origin/trunk is a shorthand saying you want the diff between the common ancestor, so it doesn't give you a diff removing everything added to the original project since you started, it just gives you the changes you've made on your branch.

Scott Chacon
Good detailled explanation. +1. On the '`...`' syntax, see http://stackoverflow.com/questions/2539040/not-able-to-think-of-a-case-where-git-diff-master-lab-and-git-diff-master-lab and http://stackoverflow.com/questions/53569/how-to-get-the-changes-on-a-branch-in-git/53573#53573, and the very complete answer: http://stackoverflow.com/questions/850607/difference-in-git-log-origin-master-vs-git-log-origin-master
VonC
I keep on getting following error. How do I fix it ?[prafulla@prafulla-laptop hive] $git log --oneline origin/trunk ^mirror/trunkwarning: refname 'origin/trunk' is ambiguous.warning: refname 'mirror/trunk' is ambiguous.
Prafulla
It looks like you might have accidentally created a local tracking branch named 'origin/trunk', which is common, and unfortunate that git even lets you do it. You can fix that by running `git log refs/remotes/origin/trunk ^mirror/trunk` instead - that will make it non-ambiguous. I would tell you to delete your local (`refs/heads/origin/trunk`) reference, but you might have work on it, I would have to see all of your references. You can run `git for-each-ref` and paste the output here and I can tell you if you can safely delete it.
Scott Chacon
it might also be worth taking some time and reading something like Pro Git (http://progit.org/book) to learn Git a bit better if you're doing this much work in it.
Scott Chacon