I have a repository that has mounted another repository with
git subtree add -P some/path otherremote otherbranch
development has gone on with some local changes, but also with a few rounds of merges done with:
git fetch otherremote
git subtree merge -P some/path otherremote/otherbranch
git commit
Now I want to get a diff between the HEAD of otherremote/otherbranch and the tree at some/path. How can I do this?
Adding a subtreeSpecify the prefix local directory into which you want to pull the subtree. Specify the remote repository URL [of the subtree being pulled in] Specify the remote branch [of the subtree being pulled in] Specify you want to squash all the remote repository's [the subtree's] logs.
If there is an external repository you own and are likely to push code back to, use Git submodule since it is easier to push. If you have third-party code that you are unlikely to push to, use Git subtree since it is easier to pull.
A Git subtree is a replica of a Git repository that has been dragged into the main repository. A Git submodule is a reference to a particular commit in a different repository. Git subtrees, which were first introduced in Git 1.7. 11, help you make a copy of any repo into a subdirectory of another.
Splitting the Original Repository The subtree commands effectively take a folder and split to another repository. Everything you want in the subtree repo will need to be in the same folder.
This should be what you're looking for:
git diff otherremote/otherbranch commit:some/path
You can even compare against previous revisions, using all the standard commit
naming conventions.
For example, I've made a remote repo u-boot
, master
branch, a subtree of my main repo at u-boot/
. To see the changes I've made in my local master branch since a specific version in the remote repo:
git diff u-boot/master~17 master:u-boot/
Tested using git 1.9.0, though I'm pretty sure this generally works with older versions as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With