我想在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/
目录如何删除?