【git】main|REBASE 2/6

  • 很久没合并代码
  • 合并出现冲突,自动进入了 main|REBASE 2/6 的提示:

【git】main|REBASE 2/6

It looks like you've encountered several merge conflicts after a git pull operation while a rebase is in progress. Here's how you can resolve these conflicts and proceed with your rebase:

Resolve Merge Conflicts Manually:

Open the conflicting files in your code editor.

Look for the conflict markers (<<<<<<<, =======, >>>>>>>). These mark the conflicting changes from the local and remote versions.

Decide how to integrate changes from both sides or choose one side over the other.

After resolving each conflict in a file, save the file.

Mark Conflicts as Resolved:

Use git add for each file you resolve to mark it as resolved. Do not use git commit yet as the rebase process will handle committing for you.

Continue the Rebase:

Once all conflicts are resolved and the files are added, continue the rebase by running:

bash 复制代码
git rebase --continue

This will apply the next commit in the rebase queue and might result in more conflicts. Repeat the resolution process as needed.

Skip the Problematic Commit (if you decide the commit causing conflicts should not be applied):

You can use:

bash 复制代码
git rebase --skip

This will ignore the commit that causes the conflict and move to the next commit.

Abort the Rebase (if you decide to return to the original state before the rebase started):

You can abort the rebase which will return your branch to the original state before the rebase started:

bash 复制代码
git rebase --abort

It's important to carefully review the changes and ensure that the resolution maintains the integrity and functionality of the code. If the rebase was unintentional or if you're unsure about how to resolve conflicts, it might be safer to discuss with your team or check with the repository's main contributor.

我的修复

bash 复制代码
zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$ git pull
remote: Enumerating objects: 772, done.
remote: Counting objects: 100% (772/772), done.
remote: Compressing objects: 100% (661/661), done.
remote: Total 772 (delta 118), reused 712 (delta 104), pack-reused 0
Receiving objects: 100% (772/772), 25.54 MiB | 10.37 MiB/s, done.
Resolving deltas: 100% (118/118), completed with 9 local objects.

   dd374ac3..e80e2164  main       -> origin/main
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
Auto-merging Bifrost-202403/worker/src/bifrost/experiment_manager/h264_file_data_producer.cpp
CONFLICT (content): Merge conflict in Bifrost-202403/worker/src/bifrost/experiment_manager/h264_file_data_producer.cpp
warning: Cannot merge binary files: player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib (HEAD vs. 4db9a18e (同步13900k的修改,主要合并了player-only、2403版本的wsl2调试))
Auto-merging player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib
CONFLICT (content): Merge conflict in player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib
Auto-merging player-only/worker/third_party/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc
error: could not apply 4db9a18e... 同步13900k的修改,主要合并了player-only、2403版本的wsl2调试
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 4db9a18e... 同步13900k的修改,主要合并了player-only、2403版本的wsl2调试

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$ git rebase --continue
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
error: could not apply 0c2cdc98... 忽略俩264文件
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 0c2cdc98... 忽略俩264文件

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 3/6)
$ git rebase --continue
.gitignore: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 3/6)
$ git rebase --continue
[detached HEAD 2a348e6d] 忽略俩264文件
 1 file changed, 3 insertions(+), 1 deletion(-)
CONFLICT (modify/delete): player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.pdb deleted in f466da41 (abseil的m77版本的absl不上传) and modified in HEAD.  Version HEAD of player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.pdb left in tree.
error: could not apply f466da41... abseil的m77版本的absl不上传
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply f466da41... abseil的m77版本的absl不上传

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 6/6)
$ git rebase --continue
player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.pdb: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 6/6)
$ git rebase --abort

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$

重新push pull:刚才的修改都丢失了

bash 复制代码
zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$ git push

 ! [rejected]          main -> main (non-fast-forward)

hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. If you want to integrate the remote changes,
hint: use 'git pull' before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$ git pull
Auto-merging .gitignore
CONFLICT (content): Merge conflict in .gitignore
Auto-merging Bifrost-202403/worker/src/bifrost/experiment_manager/h264_file_data_producer.cpp
CONFLICT (content): Merge conflict in Bifrost-202403/worker/src/bifrost/experiment_manager/h264_file_data_producer.cpp
warning: Cannot merge binary files: player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib (HEAD vs. 4db9a18e (同步13900k的修改,主要合并了player-only、2403版本的wsl2调试))
Auto-merging player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib
CONFLICT (content): Merge conflict in player-only/worker/third_party/libwebrtc/deps/abseil-cpp/abseil-cpp_m77/out32/Debug/absl.lib
Auto-merging player-only/worker/third_party/libwebrtc/libwebrtc/modules/pacing/paced_sender.cc
error: could not apply 4db9a18e... 同步13900k的修改,主要合并了player-only、2403版本的wsl2调试
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 4db9a18e... 同步13900k的修改,主要合并了player-only、2403版本的wsl2调试

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$ ^C

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$

本地修改后后强制覆盖线上版本

如果你想要在Git中强制使用本地的更改覆盖远程仓库的更改(例如在解决合并冲突后),你可以使用以下步骤来强制推送:

确保你的本地分支已正确设置: 确保你已经解决了所有合并冲突,并且你的本地分支包含了所有你希望在远程仓库中有的更改。

使用强制推送: 强制推送会使远程分支与你的本地分支同步,即使这意味着覆盖在远程分支上的更改。使用以下命令进行强制推送:

bash

复制代码

git push origin --force

或者使用更安全的方式,只强制推送你的当前分支:

bash

复制代码

git push --force-with-lease

这个命令在远程分支没有被其他人更新的情况下执行推送,这是一种更安全的做法,可以防止无意中覆盖其他人的更改。

警告:

强制推送是一个危险的操作,因为它会永久覆盖远程仓库中的更改。在进行强制推送前,最好确认与你的团队或项目的贡献者。

确保你理解强制推送会使远程仓库丢失所有未合并的更改。

通常,如果不是在个人项目或在确保所有团队成员都同意的情况下,应避免使用强制推送。

在团队环境中,建议在执行此类操作前进行充分的沟通。

我的操作

bash 复制代码
zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$ git push --force-with-lease
fatal: You are not currently on a branch.
To push the history leading to the current (detached HEAD)
state now, use

    git push origin HEAD:<name-of-remote-branch>


zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$ git push -^Corce-with-lease

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main|REBASE 2/6)
$ git rebase --abort

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$ git push --force-with-lease
Enumerating objects: 123, done.
Counting objects: 100% (123/123), done.
Delta compression using up to 32 threads
Compressing objects:  98% (76/77)
Compressing objects: 100% (77/77), done.
Writing objects: 100% (81/81), 2.61 MiB | 5.65 MiB/s, done.
Total 81 (delta 54), reused 2 (delta 1), pack-reused 0
remote: Powered by GITEE.COM [1.1.5]
remote: Set trace flag 8545d1b1

 + e80e2164...f466da41 main -> main (forced update)

zhangbin@DESKTOP-1723CM1 MINGW64 /d/XTRANS/thunderbolt/ayame/zhb-bifrost (main)
$
相关推荐
和你一起去月球3 小时前
TypeScript - 函数(下)
javascript·git·typescript
我不是程序猿儿4 小时前
【GIT】TortoiseGit的变基(Rebase)操作
git
yyycqupt10 小时前
git使用(一)
git
Kkooe14 小时前
GitLab|数据迁移
运维·服务器·git
Beekeeper&&P...15 小时前
git bash是什么,git是什么,git中的暂存区是什么,git中的本地仓库是什么,git中工作目录指的是什么
开发语言·git·bash
Stara051119 小时前
Git推送+拉去+uwsgi+Nginx服务器部署项目
git·python·mysql·nginx·gitee·github·uwsgi
lsswear19 小时前
GIT 操作
git
勋勋勋勋小勋勋20 小时前
git分支合并某一次提交
git
PandaCave21 小时前
git常用命令以及注意事项总结
git