我想将一个分支重新设置为主分支,所以我这样做了
git checkout MyAwesomeBranch
git rebase main
问题是我明白了
Using index info to reconstruct a base tree...
.git/rebase-apply/patch:68: trailing whitespace.
.git/rebase-apply/patch:72: trailing whitespace.
warning: 2 lines add whitespace errors.
Falling back to patching base and 3-way merge...
error: The following untracked working tree files would be overwritten by merge:
captioning/trial_image.py
Please move or remove them before you merge.
Aborting
error: Failed to merge in the changes.
Patch failed at 0003 trial
hint: 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".
我不确定,但我认为问题是后来我让
captioning/trial_image.py
变得不受追踪。
我该如何克服这个问题?
您在 git rebase 过程中遇到了一些问题。以下是解决这些问题的方法:
有关空格错误的警告通知您存在带有尾随空格的行。您可以通过配置 Git 自动修剪尾随空格来防止这些警告:
git config --global core.whitespace trailing-space,space-before-tab
git config --global apply.whitespace fix
错误消息表明您的工作目录中有未跟踪的文件,合并将覆盖这些文件。要解决此问题,您有两种选择: 如果不需要captioning/Trial_image.py,您可以将其删除。如果需要,请将其移动到其他位置。
rm captioning/trial_image.py # Remove the file
如果这些文件应该是存储库的一部分,请将它们添加到暂存区域并在继续变基之前提交它们。
git add captioning/trial_image.py
git commit -m "Add trial_image.py"
解决冲突或移动/删除未跟踪的文件后,您可以继续变基过程:
git rebase --continue