比如说,如果文件foo
已经提交,则其内容为
just a simple line
现在git checkout -b issue57
已完成创建分支并切换到它(例如,issue57分支将持续2天进行开发),并且现在将一行footer added
添加到文件中,然后是git commit -a -m "add a footer to the file"
。
所以现在文件foo
有内容
just a simple line
footer added
当需要“热修复”或“快速修复”时,我认为应该使用命令git checkout master
,现在文件foo
的内容应该只返回一个线。但是当我more foo
时,文件有两行,为什么会这样?
答案 0 :(得分: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
之前提交了文件?