I had trouble trying to get my coworker new created tags when he told me he already pushed them up and they where up in the repo. It wasn't until I used git fetch when I could get the new tag and actually informed me about a new branch created. I knew git pull is basically git fetch & git merge so I was wondering why it wasn't getting the latest changes. Here are the two situations:
git pull origin dev
From ******.****.*****/*******
* branch dev -> FETCH_HEAD
Already up-to-date.
git fetch
From ****.****.com:*******/*******
ae06d29..958f332 master -> origin/master
* [new branch] task-Q -> origin/task-Q
* [new tag] demo_5-21 -> demo_5-21
* [new tag] demo_5_27 -> demo_5_27
Was I missing something?
Looking at the synopsis of git pull
we see:
'git pull' [options] [<repository> [<refspec>...]]
When you run git pull origin dev
you are specifying that you want to pull the refspec dev
from the remote origin
. Since you're specifically asking for the dev
branch, no other branches or tags are pulled.
Instead, try git pull --all
.
Yes: 'git pull' is a 'git fetch; git merge'.
No: 'git fetch --all' will not fetch all tags by default without '--tags' ... it will fetch reachable tags, see third part of my answer below.
Likewise: 'git push' does not push tags by default without '--tags'.
Your git pull origin dev
fetched only the remote dev branch. If you had typed git pull
or git pull origin
you would get the new branch ... depending on the configuration. What is fetched is controlled by three things, you probably took advantage of the last one:
Command line: While git pull --tags
works, it won't necessarily fetch tracking branches ... and git reminds you to use git fetch --tags
. This would have fetched your coworker's tags, but not any branches.
$ git pull --tags
. . .
Fetching tags only, you probably meant:
git fetch --tags
Remote/branch fetch configuration: With bare git fetch
or git fetch origin
the remote and branch configuration controls behavior. These didn't come into play:
$ git config remote.origin.fetch
+refs/heads/*:refs/remotes/origin/*
$ git config --get-regexp 'branch.master*'
branch.master.remote origin
branch.master.merge refs/heads/master
Upstream branch/tag history: According to the second paragraph of the git fetch documentation
By default, any tag that points into the histories being fetched is also fetched; the effect is to fetch tags that point at branches that you are interested in.
This means that when your coworker pushed a branch with new tags in its history, your git fetch
got the new branch and the new tags.
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