---
title: "Git checkout指定tag的代码"
author: "jaychang"
date: "2017-12-04T13:48:39Z"
tags: []
categories: ["开源软件"]
slug: "git-checkout-tag"
draft: false
lastmod: "2017-12-04T13:48:39Z"
id: 2403629
url: "https://jaychang.iteye.com/blog/2403629"
---

有时候，想要拉取特定标签的代码，比如说1.0.0标签名的代码？

## clone

1

$ git clone

先使用git clone克隆这个代码仓库。

## checkout

1

2

$ git tag -l

$ git checkout tags/&lt;tag\_name&gt;

克隆完代码仓库后，通过检出特定标签的代码。

## 创建分支

1

$ git checkout tags/&lt;tag\_name&gt; -b &lt;branch\_name&gt;

更好的方法，检出代码后创建一个新的分支，否则你将会在一个用标签版本号命名的分支上。

## 参考

[Download a specific tag with Git](http://stackoverflow.com/questions/791959/download-a-specific-tag-with-git)