Trying to diff
my local file with a GitHub repo before I submit a pull request so I can see what will show up, is there an accurate way of doing this? I assume
Don't do a pull
:
fetch
(the syntax is the same as git pull
, but it doesn't automatically merge)diff
between your dest branch and the other branchmerge
if you wantTo compare a local working directory against a remote branch, for example origin/master:
git fetch origin master
git fetch
will not affect the files in your working directory; it does not try to merge changes like git pull
does. git diff --summary FETCH_HEAD
--stat
instead of --summary
. git diff FETCH_HEAD -- mydir/myfile.js
--summary
option and reference the file you want (or tree).As noted, origin
references the remote repository and master
references the branch within that repo. By default, git uses the name origin
for a remote, so if you do git clone <url>
it will by default call that remote origin
. Use git remote -v
to see what origin
points to.
You may have more than one remote. For example, if you "fork" a project on GitHub, you typically need a remote referencing the original project as well as your own fork. Say you create https://github.com/yourusername/someproject
as a fork of https://github.com/theoriginal/someproject
. By convention, you would name the remote to the original repo upstream
, while your own fork would be origin
. If you make changes to your fork on GitHub and want to fetch those changes locally, you would use git fetch origin master
. If the upstream
has made changes that you need to sync locally before making more changes, you would use git fetch upstream master
.
You can use: git diff remote/my_topic_branch my_topic_branch
Where my_topic_branch
is your topic branch.
Per the OP's comment that part of his "problem was Windows vs. Unix LFs" this should help:
You can use the following config command to tell git-diff to ignore the difference of eol code.
git config --global core.whitespace cr-at-eol