How can I compare two versions of software, one of which is in a GIT repo?
I using a vendor modified version Linux which is based on a 2.6.14.* (more specifically than that, I don’t know which) version of the kernel.
I’d like to forward port the vendor kernel changes, but first it makes sense to me to see what changes were made. I’ve cloned the linux git repo:
$ git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git linux-git
and would now like to do a diff, and perhaps create a branch with the vendor code. Suggestions?
3 Solutions collect form web for “How can I compare two versions of software, one of which is in a GIT repo?”
I’d suggest you first creating a branch starting from the commit that’s definitely older than the one the vendor version is based on.
Then you should checkout to that new branch, and synchronize the working copy with your vendor sources. To do that, you should delete all source files from the working copy (be sure to skip
.gitignore files!), and then copy your code there. You could try using
rsync for that.
After that, you can use
git diff to see what changes were made.
Commit these changes into the new branch with
Now switch to the master branch (
git checkout master), and rebase your new branch onto it (
git rebase new-branch). The changes that were in both branches (they appear since you don’t know the exact commit, on which the vendor’s kernel is based) will be automatically merged, and will cause no conflicts. Other conflicts have to be resolved.
After a successful rebase, your HEAD commit will contain the changes made by your vendor.
I hope this will work for a version that old.
- Create a branch with
- Copy all the changed files over the working copy.
git diffto see all changes.
I am assuming that you have a *.tar.gz archive of your vendor’s kernel. I will also
assume that your vendor started from v2.6.14. If you think your vendor started from
some other version, say v188.8.131.52, you should clone the
linux-2.6-stable.git repository instead, since it tracks all the v2.6.x.y kernels.
Here is what I suggest.
git clone .../torvalds/linux-2.6.git(as you’ve already done)
git checkout -b vendor-2.6.14 v2.6.14
this will get you a new branch,
vendor-2.6.14that we will work on.
The branch point is set to Linus’ version 2.6.14.
rm * -rf(delete all the files)
tar xzf ../vendor-sources.tar.gz(extract files from vendor)
git add --all(stage files added, modified, and removed)
git commit -m'vendor changes'
At this point you can run things like:
git diff --stat
git show, etc.
If the changes are small, you can take this patch and apply it to a different kernel baseline, say v2.6.15.
git checkout -b vendor-2.6.15 v2.6.15(create a temporary branch off v2.6.15)
git cherry-pick vendor-2.6.14(take the first, and only commit, from .14 and apply it here)
At this point you have your vendor changes in git, so you can do anything with it. You can even split the vendor change, if it’s huge, into smaller patches. The sky is the limit.