To see the differences between a local branch and a remote branch in Git, you can use the git diff
command with the name of the two branches.
For example, if you have a local branch named “feature-branch” and a remote branch named “origin/feature-branch”, you can run:
git diff feature-branch origin/feature-branch
This will show the differences between your local branch and the remote branch. If there are no differences, you won’t see any output.
Alternatively, if you want to see a summary of the differences between your local branch and its upstream branch (usually set to the corresponding remote-tracking branch), you can use:
git status
This will show whether your local branch is ahead or behind its upstream counterpart. If it’s ahead, it means that you have made some commits that haven’t been pushed yet. If it’s behind, it means that there are changes on the upstream branch that haven’t been pulled into your local repository yet.
You can also use git log
to see the commit history for each branch and compare them manually. For example:
git log --oneline --decorate --graph HEAD origin/feature-branch
This will show a visual representation of both branches’ commit histories side-by-side. You can then examine each commit to see what changes were made in each one.