赞
踩
可在github,或者gitee上建立,如下我是在gitee:
git clone克隆,具体略。
$ git tag -a 'testtag-v1' -m '测试打tag'
JHP+Administrator@jhp MINGW64 /D/test/testtag (master)
$ git tag
testtag-v1
-a:add代表添加
-m:comment,注释
格式git push <远端仓库名,默认为origin> 本地仓库名称:远端仓库名称 --tags
$ git push origin master:master --tags
Enumerating objects: 1, done.
Counting objects: 100% (1/1), done.
Writing objects: 100% (1/1), 175 bytes | 175.00 KiB/s, done.
Total 1 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dongsir2020/testtag.git
* [new tag] testtag-v1 -> testtag-v1
推送完毕后,就会在远端仓库生成一个tag,如下图:
$ git checkout -b testtag-v1-new-branch testtag-v1
Switched to a new branch 'testtag-v1-new-branch'
$ git push origin testtag-v1-new-branch:testtag-v1-new-branch
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
remote: Create a pull request for 'testtag-v1-new-branch' on Gitee by visiting:
remote: https://gitee.com/dongsir2020/testtag/pull/new/dongsir2020:testtag-v1-new-branch...dongsir2020:master
To https://gitee.com/dongsir2020/testtag.git
* [new branch] testtag-v1-new-branch -> testtag-v1-new-branch
推送成功后将会在远端生成仓库,如下图:
如果是设置,当前本地分支没有追踪到任何远端分支,如下:
$ git branch -vv
master 9940582 [origin/master] Initial commit
* testtag-v1-new-branch 9940582 Initial commit
设置追踪:
$ git push --set-upstream origin testtag-v1-new-branch:testtag-v1-new-branch
Everything up-to-date
Branch 'testtag-v1-new-branch' set up to track remote branch 'testtag-v1-new-branch' from 'origin'.
再次查看追踪情况:
$ git branch -vv
master 9940582 [origin/master] Initial commit
* testtag-v1-new-branch 9940582 [origin/testtag-v1-new-branch] Initial commit
可以看到本地分支testtag-v1-new-branch
,已经追踪到远端分支origin/testtag-v1-new-branch
了,这之后当我们使用git pull
,git push
时就会默认从追踪的远端分支拉取和推送代码了。当然也可以通过指定远端分支的方式显示的推送或者是拉取,如下就是将本地分支testtag-v1-new-branch
,推送到远端分支origin/master
。
$ git push origin testtag-v1-new-branch:master
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0
remote: Powered by GITEE.COM [GNK-5.0]
To https://gitee.com/dongsir2020/testtag.git
9940582..a85d924 testtag-v1-new-branch -> master
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。