Reputation: 852
I have forked the git repository of a project on Github and made my own changes to it. I wanted to get a diff between my repository and the original repository that I've forked. Can someone tell me the 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 the 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 other posted questions regarding the same topic and could not get it to work.
Any help would be highly appreciated.
Upvotes: 22
Views: 33255
Reputation: 450
There is a flaw in this, in case anyone comes across this question again.
[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
Whenever you do a git fetch on mirror it overwrites the same remote branch in your .git/refs/remotes. You should make sure to change the remote mirror fetch to reflect the new name.
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = giturl
[remote "mirror"]
fetch = +refs/heads/*:refs/remotes/mirror/*
url = giturl
Then a simple
git diff origin/master..mirror/master
Upvotes: 5
Reputation: 388413
git diff origin/master mirror/master
Something along that should do the trick.
Upvotes: 2
Reputation: 4946
One downside of the approaches above is that they diff a specific pair of branches. If you want to find all commits where your local repo differs from the remote -- across all branches you may have created, even if some aren't merged back into master yet -- you can do the following:
git log --branches --not --remotes
Upvotes: 0
Reputation: 2786
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.
Upvotes: 15
Reputation: 852
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!.......
Upvotes: 3