There are many similar questions but my question is little different.
I am a tester and have limited knowledge about git. I have cloned a project and created a local workspace. When I want to get latest source code, I use
git diff master
This is the real basics of Git. I strongly recommend going through a visual git tutorial (just google that). Also, I recommend getting the open source GUI tool Git Extensions so you can visually see your commits/branches and learn different commands easier.
originby default) into a local repo on your PC.
git fetch), and then will
git mergeyour local
masterbranch into the remote
masterbranch that you just pulled down.
git diff HEAD.
Although it's really easy in Git Extensions to see the current changes - just hit the "Commit" button, and a window pops up with the Working directory on top left, index on bottom left, and if you click on any file in them, you'll see all the changes for that file on the Right side.
(Sorry - couldn't resist the Star Wars quote)
Okay, I finally understand your core question - you are not making changes to the local repo, you just want to see the changes between the repo before the pull and after the pull - to see what changed since the last time you pulled.
This can be done by getting the hash of the last commit on
master before the pull, and then using:
git diff <hash of prior commit> HEAD
HEAD refers to whichever commit is currently checked out, either the current commit of the branch you checked out, or a particular commit if you checked one out directly (this is a state called a "detached HEAD").
HEAD will point to
master which will should point to the latest commit in the repo after a successful pull.
Instead of using
HEAD, you could put the actual hash of the latest commit. Note that if you know how many commits were pulled down, you don't even need to know the commit hashes. For example, if the prior commit was 2 commits back, you can use:
git diff HEAD~2 HEAD
The HEAD~2 just looks 2 commits back in the log from HEAD, and uses that hash.
To do this with a GUI, in Git Extensions, you can just right-click on the prior commit and select "Compare > Compare to current branch" in order to pull up the diff window with the changes between that commit and the current location of your current branch.
The currently checked out branch/commit is shown in bold in Git Extensions, and should always be at the top of the list and have a
>master tag next to it for your situation.