From: Jeff King <peff@peff.net>
To: Dominik Salvet <dominik.salvet@gmail.com>
Cc: git@vger.kernel.org
Subject: Re: Fetching master branch with tags associated with it
Date: Fri, 22 Feb 2019 11:07:22 -0500 [thread overview]
Message-ID: <20190222160722.GA22531@sigill.intra.peff.net> (raw)
In-Reply-To: <CAEXP2g92_pnbh4_V8VOgzzdUv6w5eDhCsXf=+NOdsRwyjQUb5A@mail.gmail.com>
On Thu, Feb 21, 2019 at 06:02:54PM +0100, Dominik Salvet wrote:
> Now, I want to refresh the repository the same way - fetching only
> commits from the master branch and tags that are pointing to the
> master branch and also refresh those tags as well in case of their
> target commit change at the remote (you can expect that it always
> points to a master commit). Nevertheless, I don't really know how to
> do it. The closest I got, are the following commands:
>
> ```sh
> git fetch --tags origin master &&
> git merge FETCH_HEAD
> ```
>
> However, there obviously are some problems with this solution. The
> `--tags` flag will cause to fetch tags from all branches. Furthermore,
> it will fetch also their commits, which is absolutely what I don't
> want to.
>
> I have Git 2.17.1 (on Ubuntu 18.04.2) and in its `git fetch --help` is
> stated, if I understood it correctly, that without passing neither
> `--tags` nor `--no-tags`, it will do exactly what I want.
> Nevertheless, without using any of the mentioned flags, it behaves
> more like using `--no-tags`.
Generally yes, that's how it's supposed to work. However, I think
tag-following does not kick in when you've given a specific refspec.
So take this toy setup for example:
-- >8 --
git init repo
cd repo
# one tags accessible from master
git commit --allow-empty -m one
git tag one
# one tag accessible only from "other"
git checkout -b other
git commit --allow-empty -m two
git tag two
# now fetch into another repository
git init child
cd child
git remote add origin ..
git fetch origin master
-- 8< --
That won't pick up the "one" tag in that final fetch. But if you use the
normal configured refspec (but tell it only to grab "master"):
git config remote.origin.fetch refs/heads/master:refs/remotes/origin/master
git fetch origin
then it works. I don't know if there's a less-awkward way to get what
you want, though. It really seems like there should be a "--tags=follow"
or similar.
-Peff
next prev parent reply other threads:[~2019-02-22 16:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-02-21 17:02 Fetching master branch with tags associated with it Dominik Salvet
2019-02-22 16:07 ` Jeff King [this message]
2019-02-22 16:35 ` Randall S. Becker
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190222160722.GA22531@sigill.intra.peff.net \
--to=peff@peff.net \
--cc=dominik.salvet@gmail.com \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).