I want to compare the local clone of a repository I have forked with the original/upstream repository to see if further commits have been made requiring me to pull/merge. I'd like to do this from the command line.
I added the original repository to my list of remotes with this command:
git remote add upstream <original repo URL>
This is outlined in Github's own page on the topic of forking a branch.
However, when I run git diff upstream
or git diff upstream/master
as advised here or git diff master upstream/master
as advised here, I get this:
fatal: ambiguous argument 'upstream': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
The command git diff origin/master
does not return an error (or anything for that matter). Have I missed something?
Before one can run a git diff
between one's own local repo and the upstream, one must first fetch the upstream repo. The comparison is then made locally.
git fetch upstream
This does not affect the working branch of your repo but it does add a whole other bunch of "remote" branches, which you can see with git branch -a
.
Once you've got those, use:
git diff master upstream/master
This will compare the local repository you have with any updates that have been made to the original repository. Variations on this command will deal with updates you may have made to your own branch or check against a common ancestor (e.g., git diff master...upstream/master
) as usual.
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