發生在 GitHub conflict 的衝突——無法發 PR 合併分支


Posted by estella00911 on 2021-11-03

1. 問題描述

專案資料夾結構

// 專案資料夾結構
|- blog/  // 放置 blog 作品的資料夾
|- board/ // 放置 board 作品的資料夾
|- src_demo/ // 放置 README.md demo 的 gif / 圖片
|- README.md

git status 狀態

branch:

  1. main (default)
  2. blog

(1) main (default):

距離上一次的 commit 為 10/29,然後在 main 主分支上,又有尚未被追蹤的檔案—— blog,

$ git log
commit 877115c3e8f6d0bf733565959fd19c8c66862f41
Author: estella00911 <estella00911@gmail.com>
Date:   Fri Oct 29 16:19:34 2021 +0800

    updage base url for single article page
$ git status
位於分支 main
未追蹤的檔案:
  (使用 "git add <檔案>..." 以包含要提交的內容)
    blog/

(2) blog:

$ git log
commit ef5917f80ecf3c83a7bc330367ec3132f78a4c46
Author: estella00911 <estella00911@gmail.com>
Date:   Tue Nov 2 23:16:04 2021 +0800

    update css in nav and complete pagination 1st ver.
$ git status
位於分支 blog
沒有要提交的檔案,工作區為乾淨狀態

無法在 GitHub 上發 Pull Request

"Can’t automatically merge. Don’t worry, you can still create the pull request."

解決方法

參考 GitHub "can't automatically merge"? 這篇的以下方法

git checkout master
git pull
git checkout your-branch
git merge master

然後在 local 端會列出發生衝突的檔案,點進去檔案觀看,會發現檔案內容,會把 current branch 及 main 不同之處使用以下標示:

>>>> current
======
<<<< HEAD

此時將需要的內容留下,重複的地方刪除,並刪除提示( >>>>>=====<<<<
再進行一次 git add、commit、push 就可以了!


#conflict #Github







Related Posts

#001_0612 始まる。

#001_0612 始まる。

[Preparation for Interview Basic 1] DOM Element

[Preparation for Interview Basic 1] DOM Element

 API

API


Comments