2

说,如果文件foo已经提交,则内容为

just a simple line

现在 agit checkout -b issue57完成创建一个分支并切换到它(例如,那个 issue57 分支将持续 2 天用于开发),并且footer added现在将一行添加到文件中,然后 a git commit -a -m "add a footer to the file".

所以现在文件foo有内容

just a simple line
footer added

当需要“热修复”或“快速修复”时,我认为git checkout master应该使用命令,现在文件的内容foo应该回到那一行。但是当我这样做时more foo,文件有两行,这是为什么呢?

4

1 回答 1

4

对我来说很好用:

$ more foo
just a simple line
$ echo "footer added" >> foo
$ git checkout -b issue57
M   foo
Switched to a new branch 'issue57'
$ git commit -a -m "add a footer to the file"
[issue57 c397054] add a footer to the file
1 file changed, 1 insertion(+)
$ more foo
just a simple line
footer added
$ git checkout master
$ more foo
just a simple line

也许你以前提交过文件git checkout -b issue57

于 2012-08-29T07:22:17.647 回答