gpt4 book ai didi

Git rebase vs merge。如果 git rebase 会使标签丢失?

转载 作者:太空狗 更新时间:2023-10-29 14:41:37 24 4
gpt4 key购买 nike

A-B-C-D-E-F     master
\
H-I-J feature
|
tag v1.0

如果我重新获得主功能会怎样? tag1.0 会丢失吗?

最佳答案

标签不会丢失,但它可能不会执行您想要的操作。那就是标签将保留在 I 上:

A-B-C-D-E-F          master
| \
\ H'-I'-J' feature
H-I-J
|
tag v1.0

试一试:

$ git init
$ for c in {A..F}; do touch $c; git add $c; git commit -m $c; done
$ git checkout -b feature HEAD^{/C}
$ for c in {H..J}; do touch $c; git add $c; git commit -m $c; done
$ git tag 'tag-v1.0' feature^{/I}

$ git log --graph --decorate --all --oneline
* d782b9d (HEAD -> feature) J
* c0df2db (tag: tag-v1.0) I
* 2a9fb01 H
| * 3018edf (master) F
| * e0eabe0 E
| * daab573 D
|/
* 8ebf4bb C
* 82be26d B
* 8379c01 A
$ git rebase master feature

$ git log --graph --decorate --all --oneline
* 091cf03 (HEAD -> feature) J
* 6327f84 I
* 69123dd H
* 3018edf (master) F
* e0eabe0 E
* daab573 D
| * c0df2db (tag: tag-v1.0) I
| * 2a9fb01 H
|/
* 8ebf4bb C
* 82be26d B
* 8379c01 A

注意事项:

HEAD^{/C}引用可从 HEAD 访问的最新提交,其消息匹配 C , 请参阅 gitrevisions :

<rev>^{/<text>}, e.g. HEAD^{/fix nasty bug}

A suffix ^ to a revision parameter, followed by a brace pair that contains a text led by a slash, is the same as the :/fix nasty bug syntax below except that it returns the youngest matching commit which is reachable from the <rev> before ^.

关于Git rebase vs merge。如果 git rebase 会使标签丢失?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53481774/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com