Reputation: 11454
I was trying to compare changes I made to a forked repo.
To make this real, here is the example:
git clone [email protected]:steranka/udemy-sfg-di.git
git checkout property-source
.git push
Now I want to compare my changes to the equivalent branch on the original repo.
The origin and upstream are set to:
origin: [email protected]:steranka/udemy-sfg-di.git
upstream: [email protected]:springframeworkguru/sfg-di.git
My searches indicated that there was not a built in way to do this using the git CLI, nor the github website.
What I did find was:
https://stackoverflow.com/a/66613981/3281336. Basically do the compares via local repo.
How to compare a local Git branch with its remote branch - How to compare local vs remote branch. Later, I learned this is basically what a forked repo is... Just another remote.
General info about forks (from GitHub.com) https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/working-with-forks/about-forks
https://docs.github.com/en/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-comparing-branches-in-pull-requests - The GitHub.com docs indicate that this is doable if you create a pull request. This is not what I want to do.
How do you do this? I ran across gh-cli which might do it.
Can this be done via the github.com web interface? If so, how?
Upvotes: 2
Views: 1423
Reputation: 11454
I've selected the answer from Matt because that is the answer I was looking for. But another possible solution is based on @torek's answer.
The solution is to pull the upstream repo's branch that you want to compare locally and then do normal git diff commands. The result is that the compares are done via my local repo.
The steps to do this are:
The code commands to do this are:
git remote add upstream [email protected]:springframeworkguru/sfg-di.git
git fetch upstream property-source
git diff upstream/property-source..
This turned out to be simpler than I expected.
One benefit of this approach over the GITHUB web ui is I could compare my code changes without pushing my code to the github.
Upvotes: 0
Reputation: 535096
Append /compare
to the URL of your repo. Example (try it):
https://github.com/mattneub/amperfy/compare
That's a public fork of a public upstream. You can select two branches, possibly at the two different repos, to see the diff.
Upvotes: 4