Reputation: 131078
I fetch a branch from a remote repository. How can I see that it has worked successfully? I expect that after this fetch I should have a (copy of) remote branch locally but I cannot find it (neither with git branch
nor git branch -r
nor git status
). To me it looks like nothing has happened.
Upvotes: 1
Views: 7128
Reputation: 21938
First, to be sure to get an output, whether new branches or commits are actually found on the remote end, you can go for the verbose fetch :
git fetch -v
Then any non-updated remote branch will show up in the output as (for example)
= [up to date] my_awesome_branch -> origin/my_awesome_branch
= [up to date] yet_another_branch -> origin/yet_another_branch
But beyond this, even after having successful fetched and now having fresh references in your local repo, note that at this point only remote-tracking branches are updated to reflect the state of their counterparts on the remote end.
Your local branches, however, are still in the state they were before the fetch operation.
With this fetch output example :
$ git fetch
remote: Counting objects: 143, done.
remote: Compressing objects: 100% (143/143), done.
remote: Total 143 (delta 118), reused 0 (delta 0)
Receiving objects: 100% (143/143), 16.54 KiB | 1.65 MiB/s, done.
Resolving deltas: 100% (118/118), completed with 53 local objects.
From ssh://<repoNameRedacted>
* [new branch] feature-2541 -> origin/feature-2541
433c28824..9924cc527 bugfix-9891 -> origin/bugfix-9891
If you were to now work on bugfix-9891 and get the most recent work, doing
git checkout bugfix-9891
...would point your HEAD at this local branch, allowing you to work on it, but you would not have the most recent commits, even though you fetched them just beforehand. They're in the remote-tracking origin/bugfix-9891
but still not in your local version bugfix-9891
.
To actually incorporate these changes and work on top of them, you'll have to
git checkout bugfix/9891
git merge origin/bugfix/9891
Let's also note that there is a very common (though by no means necessary) way to automate the [fetch + merge with remote] process, namely :
git checkout bugfix/9891
git pull
Upvotes: 2
Reputation: 3576
I believe you meant to do GIT PULL, not GIT FETCH.
Or perhaps you meant to do GIT CLONE.
GIT FETCH will not change any files in your current branch, it will only update your repository.
Upvotes: 0
Reputation: 3650
After you fetched, to see what remote "master" has compared to your local "master", you ask Git to show you exactly this:
git log origin/master ^master
which means «all commits reachable from "origin/master" which do not include commits reachable from "master"» or, alternatively
git log master..origin/master
also, git diff master origin/master
seems to address the question very simply I think.
Upvotes: 1