bash 将标记的提交合并到分支中

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9550060/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 01:42:55  来源:igfitidea点击:

Merging a tagged commit into a branch

gitbashshellversion-controlterminal

提问by Dan Lister

I'm currently trying to merge a tag into a branch. The tag is not, I would consider, of an unusual format but Git persists on displaying Vim to enter a merge message even with one supplied in the command. Take the following for example:

我目前正在尝试将标签合并到一个分支中。我认为该标签不是一种不寻常的格式,但 Git 坚持显示 Vim 以输入合并消息,即使命令中提供了一条。以以下为例:

git merge --no-ff -m "Released v1.1.0.1 to master." v1.1.0.1

I believe it has something to do with the tag format. I have tried merging branches and tags without full stops inside but the above ceases to complete without bypassing vim. I was just wondering if anybody had any advice on this issue?

我相信这与标签格式有关。我曾尝试在内部没有句号的情况下合并分支和标签,但上述内容在没有绕过 vim 的情况下停止完成。我只是想知道是否有人对这个问题有任何建议?

采纳答案by devguydavid

I just tried this with this version:

我刚刚用这个版本试过这个:

david@davids-imac:~/t (master) $ git --version
git version 1.7.5.4

on Mac OS X 10.7 and, unless I misunderstood your question, it worked just fine. Maybe you are on a different OS/bash that is interpreting the '.' differently? My bash version is:

在 Mac OS X 10.7 上,除非我误解了你的问题,否则它运行得很好。也许您在解释“.”的不同操作系统/bash 上。不一样?我的 bash 版本是:

3.2.48(1)-release (x86_64-apple-darwin11)

See below for the steps I took:

请参阅下面的我采取的步骤:

david@davids-imac:~/t $ git init
Initialized empty Git repository in /Users/david/t/.git/
david@davids-imac:~/t (master #) $ echo "hi" > t
david@davids-imac:~/t (master #%) $ git add t
david@davids-imac:~/t (master #) $ git commit -m 'added t'
[master (root-commit) 5f959d8] added t
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 t

One commit on master now. Next, the new branch and a tag:

现在对 master 进行一次提交。接下来,新分支和一个标签:

david@davids-imac:~/t (master) $ git checkout -b branch1
Switched to a new branch 'branch1'
david@davids-imac:~/t (branch1) $ echo "hello" > hello
david@davids-imac:~/t (branch1 %) $ git add .
david@davids-imac:~/t (branch1 +) $ git commit -m 'added hello'
[branch1 affb79a] added hello
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello
david@davids-imac:~/t (branch1) $ git tag v1.1.0.1

I now have a branch with a separate commit and that commit is tagged 'v1.1.0.1'.

我现在有一个单独提交的分支,该提交被标记为“v1.1.0.1”。

Now to add one more commit to master (just to make sure the branches have diverged) and merge:

现在再向 master 添加一个提交(只是为了确保分支已经发散)并合并:

david@davids-imac:~/t (branch1) $ git checkout master
Switched to branch 'master'
david@davids-imac:~/t (master) $ echo "yo" > yo
david@davids-imac:~/t (master %) $ git add .
david@davids-imac:~/t (master +) $ git commit -m 'added yo'
[master 93b09c4] added yo
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 yo
david@davids-imac:~/t (master) $ git log
commit 93b09c421e1939e3e85738fd5bd4d03b6429e729
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:24:13 2012 -0600

    added yo

commit 5f959d85a3059c189121c2b8687788c4384f9e6a
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:23:01 2012 -0600

    added t
david@davids-imac:~/t (master) $ git merge --no-ff -m "Released v1.1.0.1 to master." v1.1.0.1
Merge made by recursive.
 hello |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
 create mode 100644 hello

The merge succeeded without opening any editor:

合并成功,无需打开任何编辑器:

david@davids-imac:~/t (master) $ git log
commit ac2c62b86c3e631aeda27be601fcc92a9df61146
Merge: 93b09c4 affb79a
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:24:34 2012 -0600

    Released v1.1.0.1 to master.

commit 93b09c421e1939e3e85738fd5bd4d03b6429e729
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:24:13 2012 -0600

    added yo

commit affb79a9d72732b3250b7dca9cc8085b6f36faff
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:23:30 2012 -0600

    added hello

commit 5f959d85a3059c189121c2b8687788c4384f9e6a
Author: David Brown <[email protected]>
Date:   Wed Mar 14 20:23:01 2012 -0600

    added t