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

时间:2012-03-03 21:33:46

标签: git bash shell version-control terminal

我目前正在尝试将标记合并到分支中。我会考虑标签不是一种不寻常的格式,但是Git会继续显示Vim以输入合并消息,即使命令中提供了一个。以下面的例子为例:

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

我认为它与标签格式有关。我已经尝试合并分支和标签而没有内部完全停止,但上述内容不会绕过vim而完成。我只是想知道是否有人对此问题有任何建议?

1 个答案:

答案 0 :(得分:0)

我刚试过这个版本:

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

在Mac OS X 10.7上,除非我误解了你的问题,否则它运行得很好。也许你正在使用不同的OS / bash来解释'。'不同?我的bash版本是:

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

请参阅下面的步骤:

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

现在对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

我现在有一个带有单独提交的分支,并且该提交被标记为'v1.1.0.1'。

现在再向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 <david@davtar.org>
Date:   Wed Mar 14 20:24:13 2012 -0600

    added yo

commit 5f959d85a3059c189121c2b8687788c4384f9e6a
Author: David Brown <david@davtar.org>
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

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

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

    Released v1.1.0.1 to master.

commit 93b09c421e1939e3e85738fd5bd4d03b6429e729
Author: David Brown <david@davtar.org>
Date:   Wed Mar 14 20:24:13 2012 -0600

    added yo

commit affb79a9d72732b3250b7dca9cc8085b6f36faff
Author: David Brown <david@davtar.org>
Date:   Wed Mar 14 20:23:30 2012 -0600

    added hello

commit 5f959d85a3059c189121c2b8687788c4384f9e6a
Author: David Brown <david@davtar.org>
Date:   Wed Mar 14 20:23:01 2012 -0600

    added t