git - 如何完成这个 git rebase 操作?

标签 git rebase git-rebase

我克隆了一个远程存储库,然后从 master 中分支了一个功能分支 mybranch。几次提交后,运行 git status ,我看到:

On branch mybranch
Untracked files:
  (use "git add <file>..." to include in what will be committed)

        model/ABC/
        model/XYZ/

nothing added to commit but untracked files present (use "git add" to track)

这很好,因为我不关心 ABCXYZ 二进制目录。

现在,我想在 master 上重新建立我的分支,以纳入队友推送的最新更新。因此,我 checkout master,提取最新更改,再次 checkout mybranch 并执行以下操作:

git rebase master

rebase 运行直到我收到以下消息:

First, rewinding head to replay your work on top of it...
Dirty index: cannot apply patches (dirty: blahblah/local_install/Perl/man/man3/Convert::Binary::C.3
blahblah/local_install/Perl/man/man3/Convert::Binary::C::Cached.3
blahblah/local_install/Perl/man/man3/Digest::CRC.3)

检查此时的状态会产生:

You are currently editing a commit while rebasing branch 'mybranch' on '4e4ad5a'.
  (use "git commit --amend" to amend the current commit)
  (use "git rebase --continue" once you are satisfied with your changes)

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

        deleted:    blahblah/local_install/Perl/man/man3/Convert::Binary::C.3
        deleted:    blahblah/local_install/Perl/man/man3/Convert::Binary::C::Cached.3
        deleted:    blahblah/local_install/Perl/man/man3/Digest::CRC.3

Untracked files:
  (use "git add <file>..." to include in what will be committed)

            model/ABC/
            model/XYZ/

我们的项目(和存储库)是在 Linux-Windows 混合环境中维护的。显然,上面指出的文件是 Perl 包的 man 文件,在 Windows 环境下没有正确克隆(由于文件名难看?)

我怎样才能结束这个 rebase 操作并克服该过程的这个阶段?

更新 1:如果重要的话,可以使用稀疏 checkout 克隆本地存储库。有问题的文件属于本地工作区中的目录而不

更新2:按照@TriskalJM的回答,我在该阶段提交了更改:

git commit -m "MY-COMMENT" .

并收到此消息:

error: Invalid path 'blahblah/local_install/Perl/man/man3/Convert::Binary::C.3'
error: Invalid path 'blahblah/local_install/Perl/man/man3/Convert::Binary::C::Cached.3'
error: Invalid path 'blahblah/local_install/Perl/man/man3/Digest::CRC.3'
[detached HEAD 12d77df] MY-COMMENT
 3 files changed, 12542 deletions(-)
 delete mode 100644 blahblah/local_install/Perl/man/man3/Convert::Binary::C.3
 delete mode 100644 blahblah/local_install/Perl/man/man3/Convert::Binary::C::Cached.3
 delete mode 100644 blahblah/local_install/Perl/man/man3/Digest::CRC.3

检查状态显示rebase操作尚未完成,因此使用--continue,我收到以下消息:

sed: can't read blah/.git/rebase-apply/info: No such file or directory

有什么办法可以强制完成这个rebase吗?

最佳答案

不幸的是,您遇到了使用 git 跨平台的问题之一。将这些文件添加到存储库的开发人员犯下了严重的罪过,因为他们导致无法在 Windows 计算机上按预期使用工作流程。

您必须按原样提交更改(这将删除这些手册页),并让他们从 Linux 计算机重新提交这些页面。

此外,听起来您需要作为一个团队讨论如何在未来缓解这种情况。

此外,如果您不关心 model/ABCmodel/XYZ 因为它们包含二进制文件,您应该将它们添加到 .gitignore.

关于git - 如何完成这个 git rebase 操作?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37146922/

相关文章:

git - 有没有办法将外部文件提交到当前存储库?

Git 克隆导致 : "Cannot get remote repository information."

git - 如何使用 tortoisegit 在 git 中创建用户?

git - 如何保存git“正在重新设置基准”?

Git repo : internal and open source external branches

git - 在交互式 rebase 期间使用 git 的 prepare-commit-msg Hook

git - 如何使用 `pkg.tar.gz` 文件安装旧的 Gitkraken?

Git Merge vs Rebase - 解决冲突

git - 从 master rebase 到其他分支

git - 如何在 git 中 "rebase tags"?