在远程和分支本地版本上标记先前的git提交

时间:2013-07-23 15:36:50

标签: git

情况如下:

  1. 我之前已将代码提交到远程存储库(主版本)
  2. 我已经对本地版本进行了更改但尚未提交
  3. 我想用版本号标记远程版本,在提交之前将本地(未提交)版本分支并标记为dev或类似的东西
  4. 我该怎么做呢?

1 个答案:

答案 0 :(得分:1)

干脆做到:

$ git status .
[...]
#    modified:  README.txt
[...]

# the following will create a tag on the last commit 
#  (the one already pushed to the remote)
$ git tag -a "v0.12" -m "version 0.12"

# send the tag to the remote
$ git push --tags

# create a new branch 'dev' and immediately switch to it
$ git checkout -b "dev"

# commit the modified files to the new branch
$ git commit -m "updated README for new 'dev'-version" README.txt

# push the new branch to the remote
$ git push