我对git (来自svn)比较陌生。
我执行以下步骤,主要是编辑分支上的文件,执行存储,然后尝试将存储应用于master (没有此文件):
user1:~/gittest$ ls
user1:~/gittest$ git init
Initialized empty Git repository in /home/user1/gittest/.git/
user1:~/gittest$ touch file1
user1:~/gittest$ git add file1
user1:~/gittest$ git commit -m "committing file1"
[master (root-commit) 7c29335] committing file1
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1
user1:~/gittest$ git checkout -b br1
Switched to a new branch 'br1'
user1:~/gittest$ touch file2
user1:~/gittest$ git add file2
user1:~/gittest$ git commit -m "committing file2"
[br1 b565401] committing file2
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file2
user1:~/gittest$ echo "updated.." >> file2
user1:~/gittest$ git add file2
user1:~/gittest$ git stash
Saved working directory and index state WIP on br1: b565401 committing file2
HEAD is now at b565401 committing file2
user1:~/gittest$ git checkout master
Switched to branch 'master'
user1:~/gittest$ git stash pop
CONFLICT (modify/delete): file2 deleted in Updated upstream and modified in Stashed changes. Version Stashed changes of file2 left in tree.
user1:~/gittest$ git status
On branch master
Unmerged paths:
(use "git reset HEAD <file>..." to unstage)
(use "git add/rm <file>..." as appropriate to mark resolution)
deleted by us: file2
no changes added to commit (use "git add" and/or "git commit -a")我的问题是,既然file2从来没有在主服务器上创建过,因此也从来没有被删除过,为什么git会打印出"deleted by us“的消息呢?
这是一个误导性的信息,还是我错过了一些关于git工作方式的东西。
发布于 2016-06-01 03:25:01
这只是一条误导性的消息;它说已删除,但它根本不存在,如果从“分支角度”来看,它并不区分以前存在的文件和现在删除的文件,或者根本不存在的文件。
file2实际上是您的git存储库中的一个已知文件,因此在某种意义上,当您签出master时,它被删除了。
https://stackoverflow.com/questions/37553649
复制相似问题