首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >对于从未在master上创建的文件,git stash pop会打印"deleted by us“

对于从未在master上创建的文件,git stash pop会打印"deleted by us“
EN

Stack Overflow用户
提问于 2016-06-01 03:02:04
回答 1查看 1.4K关注 0票数 1

我对git (来自svn)比较陌生。

我执行以下步骤,主要是编辑分支上的文件,执行存储,然后尝试将存储应用于master (没有此文件):

代码语言:javascript
复制
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工作方式的东西。

EN

回答 1

Stack Overflow用户

发布于 2016-06-01 03:25:01

这只是一条误导性的消息;它说已删除,但它根本不存在,如果从“分支角度”来看,它并不区分以前存在的文件和现在删除的文件,或者根本不存在的文件。

file2实际上是您的git存储库中的一个已知文件,因此在某种意义上,当您签出master时,它被删除了。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/37553649

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档