git tag

 

git查看tag

git查看tag命令:

ershixiongdeMacBook-Pro:spring-boot zzs$ git tag
v2.2.0.M1
v2.2.0.M2
v2.2.0.M3
v2.2.0.M4
v2.2.0.M5
v2.2.0.M6
v2.2.0.RC1
v2.2.0.RELEASE
v2.2.1.RELEASE

git切换到tag

git clone整个仓库后,使用以下命令就可以取得对应tag的代码:

git checkout tag_name

此时git可能会提示你当前处于“detached HEAD” 状态。因为tag相当于一个快照,不能修改它的代码。需要在tag代码基础上做修改,并创建一个分支:

git checkout -b branch_name tag_name

上面命令的意思切换到指定的tag(tag_name),并创建一个分支,本地重新命名(branch_name)。

以SpringBoot的版本为例:

git checkout -b tag-2.2.1.RELEASE v2.2.1.RELEASE

其中tag-2.2.1.RELEASE为本地命名,v2.2.1.RELEASE为github上springboot项目自身的tag命名。

 

[root@centos7 delve]# git checkout -b remotes/origin/v1.0.0
fatal: A branch named 'remotes/origin/v1.0.0' already exists.
[root@centos7 delve]# git branch
  master
* remotes/origin/v0.12.0
  remotes/origin/v1.0.0
  v1.6.1
[root@centos7 delve]# git checkout -b remotes/origin/v1.0.0
fatal: A branch named 'remotes/origin/v1.0.0' already exists.
[root@centos7 delve]# git branch
  master
* remotes/origin/v0.12.0
  remotes/origin/v1.0.0
  v1.6.1
[root@centos7 delve]# git branch remotes/origin/v1.0.0
fatal: A branch named 'remotes/origin/v1.0.0' already exists.
[root@centos7 delve]# git checkout remotes/origin/v1.0.0
warning: refname 'remotes/origin/v1.0.0' is ambiguous.
Switched to branch 'remotes/origin/v1.0.0'
[root@centos7 delve]# git branch
  master
  remotes/origin/v0.12.0
* remotes/origin/v1.0.0
  v1.6.1
[root@centos7 delve]# 

 

 

 

 

root@ubuntu:/opt/gopath/src/github.com/kubeedge/kubeedge# git tag
v0.1
v0.2
v0.2.1
v0.3.0
v0.3.0-beta.0
v1.0.0
v1.0.0-beta.0
v1.1.0
v1.1.0-beta.0
v1.2.0
v1.2.0-beta.0
v1.2.1
v1.3.0
v1.3.0-alpha.0
v1.3.0-beta.0
v1.3.1
v1.4.0
v1.4.0-alpha.0
v1.4.0-beta.0
v1.5.0
v1.5.0-beta.0
v1.6.0
v1.6.0-beta.0
v1.6.1
root@ubuntu:/opt/gopath/src/github.com/kubeedge/kubeedge# git checkout v1.3.1
error: Your local changes to the following files would be overwritten by checkout:
        build/tools/certgen.sh
Please commit your changes or stash them before you switch branches.
Aborting
root@ubuntu:/opt/gopath/src/github.com/kubeedge/kubeedge# git clone -b v1.3.1 https://github.com/kubeedge/kubeedge.git
Cloning into 'kubeedge'...
remote: Enumerating objects: 33, done.
remote: Counting objects: 100% (33/33), done.
remote: Compressing objects: 100% (27/27), done.
remote: Total 48193 (delta 13), reused 14 (delta 6), pack-reused 48160
Receiving objects: 100% (48193/48193), 76.10 MiB | 13.38 MiB/s, done.
Resolving deltas: 100% (26258/26258), done.
Note: checking out '5bfca35b2d99a5c23b953d663723374c3f354fec'.

 

新增一份

 

 

root@ubuntu:/opt/gopath/src/github.com/kubeedge/kubeedge/kubeedge# git branch
* (no branch)

 

 

git ls-remote --tags

[root@centos7 u-boot]# git checkout v2021.10
error: pathspec 'v2021.10' did not match any file(s) known to git.
[root@centos7 u-boot]# git branch v2021.10
[root@centos7 u-boot]# git status
# On branch master
# Changes not staged for commit:
#   (use "git add <file>..." to update what will be committed)
#   (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:   Makefile
#
no changes added to commit (use "git add" and/or "git commit -a")
[root@centos7 u-boot]# git branch
* master
  v2021.10
[root@centos7 u-boot]# git checkout v2021.10
M       Makefile
Switched to branch 'v2021.10'
[root@centos7 u-boot]# 

 

posted on 2021-04-09 20:02  tycoon3  阅读(147)  评论(0)    收藏  举报

导航