Git移动了我从未移动过的文件

时间:2018-11-27 15:43:37

标签: git

我想在git中获得更多经验,所以我决定自己做一些实验。

我基本上希望看到在移动/删除/编辑文件时合并和重新设置基准之间的不同行为。

所以我创建了一个像这样的文件结构:

├── a
│   ├a.txt
│   ├aa.txt
├── b
│   ├b.txt
│   ├bb.txt
├── c
│   ├c.txt
│   ├cc.txt

每个.txt的内容只是文件名。 然后我做了三个分支

MoveATXT
DeleteATXT
EditATXT

我分别分别移动/删除/编辑了/ a中的文件a.txt 为了移动,我将/a/a.txt移至/b/a.txt 所有移动/删除操作均通过git命令git rm git mv

完成

git merge的行为是我所期望和理解的。 是git rebase使我非常困惑。

当我建立一个新分支BranchOne时,我决定先行git rebase MoveATXT,一切顺利,此举就出现了。接下来,我决定git rebase DeleteATXT这对我来说很奇怪。

它首先给我打印出错误的内容。这几乎是我所期望的。

First, rewinding head to replay your work on top of it...
Applying: Move a.txt to b/
Using index info to reconstruct a base tree...
A       a/a.txt
Falling back to patching base and 3-way merge...
CONFLICT (rename/delete): a/a.txt deleted in HEAD and renamed to b/a.txt in Move a.txt to b/. Version Move a.txt to b/ of b/a.txt left in tree.
error: Failed to merge in the changes.
Patch failed at 0001 Move a.txt to b/
Use 'git am --show-current-patch' to see the failed patch

Resolve all conflicts manually, mark them as resolved with
"git add/rm <conflicted_files>", then run "git rebase --continue".
You can instead skip this commit: run "git rebase --skip".
To abort and get back to the state before "git rebase", run "git rebase --abort".

但是我什么时候做git status

$ git status
rebase in progress; onto 7a2c06d
You are currently rebasing branch 'test' on '7a2c06d'.
  (fix conflicts and then run "git rebase --continue")
  (use "git rebase --skip" to skip this patch)
  (use "git rebase --abort" to check out the original branch)

Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        renamed:    a/aa.txt -> b/aa.txt

Unmerged paths:
  (use "git reset HEAD <file>..." to unstage)
  (use "git add <file>..." to mark resolution)

        added by them:   b/a.txt

它告诉我a/aa.txt已移至b/aa.txt

当我ls进一步显示a/丢失时,

$ ls
b/  c/

当我检查b/时,它同时具有a.txt`aa.txt

$ ls b/
a.txt  aa.txt  b.txt  bb.txt

为什么会这样?我从没动过a/aa.txt,为什么git为我动了呢? a/目录如何删除?

0 个答案:

没有答案