git fetch git log --name-status origin/master.. Will show you what commits you are about to retrieve, along with the names of the files. Based upon this reply the command "git log --graph -p" is doing a nice job. It shows tree information about the history and code changes as well.
git merge origin/master should work. Since master is usually a tracking branch, you could also do git pull from that branch and it will do a fetch & merge for you. If you have local changes on your master that aren't reflected on origin , you might want git rebase origin/master to make sure your commits are 'on top'.
If you do a git fetch it will just fetch all the changes in the remote repository (GitHub) and move the origin/master pointer to HEAD . Meanwhile your local branch master will keep pointing to where it has.
One explanation would be that the latest commits have been done on another branch, as explained in "Git pull from my public repository not working". The other possibility is for you to be in a detached HEAD mode. That would make any git pull "up-to-date" since you are in any branch.
I am learning about working with Git remotes by reading the relevant section of the Pro Git Book.
If you clone a repository, the command automatically adds that remote repository under the name "origin". So, git fetch origin
fetches any new work that has been pushed to that server since you cloned (or last fetched from) it.
It’s important to note that the git fetch
command only fetches the data to your local repository; it doesn’t automatically merge it with any of your work or modify what you’re currently working on. You have to merge it manually into your work when you’re ready.
Here is what I tried. I cloned a repository and edited a file. In the original repository, someone updated the same file and pushed. Then,
I ran git fetch
. It showed some update progress message. However, git log
did not show that update. Did I misunderstand what git fetch
does? Am I missing something?
I ran git pull
, and I got
error: Your local changes to 'hello_world.c' would be overwritten by merge. Aborting. Please, commit your changes or stash them before you can merge.
Here, I believe it's also merging and to avoid accidental data loss, it aborts.
Edit: Thanks for the answers. Actually before looking at the answers, I was trying myself and realized the same with the following commands / outputs:
$ git ls-remote origin d0006a6bfa95e0e90aa820a0e50d31a548625652 HEAD d0006a6bfa95e0e90aa820a0e50d31a548625652 refs/heads/master $ git ls-remote . 14375458b8a6b84f82d9fa4d2ded0bb8c9e87431 HEAD 14375458b8a6b84f82d9fa4d2ded0bb8c9e87431 refs/heads/master d0006a6bfa95e0e90aa820a0e50d31a548625652 refs/remotes/origin/HEAD d0006a6bfa95e0e90aa820a0e50d31a548625652 refs/remotes/origin/master
Also with following commands:
$git log origin --oneline $git log --oneline
Thank you for bearing with my stupid questions ;-)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With