Tag Archives: git

How to fetch all the tags from a remote repository in git

To fetch all the tags from a remote repository, you can use the git fetch command with the --tags option. Here’s how you do it:

git fetch --tags

This command will fetch all tags from the remote repository, as well as the commits they point to. After fetching, the tags will be available in your local repository.

If you want to fetch both the tags and the branches updates, you can use:

git fetch --all

This will fetch all branches and tags from all remotes configured for your repository. However, if you only want to update your tags to match the remote repository (which might include deleting local tags that have been removed on the remote), you can use:

git fetch --prune --tags

The --prune option will delete any local remote-tracking references that no longer exist on the remote.

Remember that fetching tags will not automatically merge any changes into your current working branch. If a tag points to commit(s) that are not in your current branch’s history, you will need to merge or rebase to include those changes in your working branch.

How to get tag create user and create time from git

We can use git tag to get all the tags from a git repository, I also want to get the tag creator and create time, the following command can get all the tag create time and creator.

git log --tags --simplify-by-decoration --pretty="format:%ci %cn %d"

From the doc for git log PRETTY FORMATS, we can get that the options meaning like below:

%ci committer date, ISO 8601-like format

%cn committer name

%d ref names, like the — decorate option of git-log[1]