I want to check the changes that will done to the files after I run git pull. I know we use git fetch to retrieve new objects from remote repository without changing local repository.
But how can I view these changes in editor ?
I want to check the changes that will done to the files after I run git pull. I know we use git fetch to retrieve new objects from remote repository without changing local repository.
But how can I view these changes in editor ?
Assuming that all your local modifications are commited, one way would be to do:
git fetch origin
# To see local changes as the "new" version
git diff origin/yourbranch HEAD
# Or to see remote changes as the "new" version
git diff HEAD origin/yourbranch
This will compare your local repository (currently HEAD) with the remote content origin/yourbranch.
to check the changes that will done to the files after I run
git pull
Then the simplest solution is just run it and look! First, work out where you are:
% git show --oneline --no-patch
bf1908d ...
Now pull, and then diff to see what you just did:
% git pull
% git diff bf1908d
This shows you exactly what you are asking for: the changes done to the files after running git pull.
If you like the changes, do nothing. If you don't, and wish you had never done this pull, then git reset --hard bf1908d and you're right back where you were before the pull, no harm done.
Once you're done git fetch, you have a full local database of all the changes on the remote, which you have just fetched, so you have all to powers of Git to explore those changes.
git log origin/branch will show you the list of commitsgit log -p origin/branch will show the commits with their changes, by commit.git diff origin/branch or git diff HEAD origin/branch (see @Gaël J's answer)If your local changes are committed, you can also check out origin/branch to play with it before going back to your own branch.
git checkout origin/branch # go to the fetched state from origin
# explore stuff
git checkout branch # go back to your own branch