使用git打tag标签 :
#Git Bash here 执行命令
#查看tag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git tag -l
RA-V1.0.2.9
#在本地打tag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git tag RA-V1.0.6.5
#再次查看tag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git tag
RA-V1.0.2.9
RA-V1.0.6.5
#将tag推到远程
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git push origin RA-V1.0.6.5
Total 0 (delta 0), reused 0 (delta 0)
To http://code./source/PKI-RA-SERVER.git
* [new tag]RA-V1.0.6.5 -> RA-V1.0.6.5
切换代码到某个tag时期:
#试一下直接切换到tag并不能 需要新建一个分支
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git checkout RA-V1.0.2.9
Note: checking out 'RA-V1.0.2.9'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b HEAD is now at 6f81ebb2 Merge branch 'dev' into 'master'
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG ((RA-V1.0.2.9))
#新建分支testTag 并切换到tag- RA-V1.0.2.9
$ git checkout -b testTag RA-V1.0.2.9
Switched to a new branch 'testTag'
#现在查看本地分支 已有testTag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git branch
dev
master
* testTag
#查看远程分支 远程还无testTag分支
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git branch -r
origin/HEAD -> origin/master
origin/dev
origin/master
origin/spring5
#将分支testTag推送到远程
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git push origin testTag
Total 0 (delta 0), reused 0 (delta 0)
To http://code./source/PKI-RA-SERVER.git
* [new branch] testTag -> testTag
#查看远程所有分支
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git branch -r
origin/HEAD -> origin/master
origin/dev
origin/master
origin/testTag
最后再删除分支:
#玩完了现在删除分支testTag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git branch -r -d origin/testTag
Deleted remote-tracking branch origin/testTag (was 6f81ebb2).
#将删除分支testTag推送到远程 (命令没错 我这里好像失败了公司权限问题吧 实际上删除成功了!)
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git push origin :testTag
remote: +---------------------------------------------------------------+
remote: | * * * PUSH REJECTED BY EVIL DRAGON BUREAUCRATS * * * |
remote: +---------------------------------------------------------------+
remote: \
remote: \ ^ /^
remote: \ / \ // \
remote: \ |\___/| / \// .\
remote: \ /V V \__ / // | \ \ *----*
remote: / / \/_/ // | \ \ \ |
remote: @___@` \/_ // | \ \ \/\ \
remote: 0/0/| \/_ // | \ \ \ \
remote: 0/0/0/0/| \/// | \ \ | |
remote: 0/0/0/0/0/_|_ / ( // | \ _\ | /
remote: 0/0/0/0/0/0/`/,_ _ _/ ) ; -. | _ _\.-~ / /
remote: ,-} _ *-.|.-~-. .~ ~
remote: * \__/ `/\ / ~-. _ .-~ /
remote: \____(Oo) *. } { /
remote: ( (..) .----~-.\ \-` .~
remote: //___\\ \ DENIED! ///.----..< \ _ -~
remote: // \\ ///-._ _ _ _ _ _ _{^ - - - - ~
remote:
remote:
remote: DANGEROUS CHANGE: The change you're attempting to push deletes the branch 'testTag'.
remote: Dangerous change protection is enabled for this repository.
remote: Edit the repository configuration before making dangerous changes.
remote:
To http://code./source/PKI-RA-SERVER.git
! [remote rejected] testTag (pre-receive hook declined)
error: failed to push some refs to 'http://code./source/PKI-RA-SERVER.git'
#切换分支到dev
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (testTag)
$ git checkout dev
Switched to branch 'dev'
Your branch is up to date with 'origin/dev'.
#查看远程分支 已无testTag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git branch -r
origin/HEAD -> origin/master
origin/dev
origin/master
origin/spring5
#查看本地分支 发现testTag还在
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git branch
* dev
master
testTag
#删除本地分支 testTag
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git branch -d testTag
Deleted branch testTag (was 6f81ebb2).
#最后再查看本地分支 ok !*代表当前所在分支
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)
$ git branch
* dev
master
admin@DESKTOP-OJDN2HN MINGW64 /d/Users/admin/work/PKI-RA-SERVER-TAG (dev)