协作头脑风暴
brainstorming
在实现前澄清需求、探索设计选择,并形成清晰的开发方向。
resolve-git-conflicts【开发与工程】Resolve merge and rebase conflicts with safe recovery strategies. Covers identifying conflict sources, reading conflict markers, choosing resolution strategies, and continuing or aborting operations safely. Use when a git merge, rebase, cherry-pick, or stash pop reports conflicts, when a git pull results in conflicting changes, or when you need to sa…
独立 GitHub 快照 · 自动分类 · 以原作者文档为准
識、解、復合與基衝。
git merge 或 git rebase 報衝git cherry-pick 不能潔施git pull 致衝變git stash pop 與工樹衝定何業致衝:
# Check current status
git status
# Look for indicators:
# "You have unmerged paths" — merge conflict
# "rebase in progress" — rebase conflict
# "cherry-pick in progress" — cherry-pick conflict
態出告何檔有衝、何業進行。
得:git status 示檔列於「Unmerged paths」並指活業。
敗:git status 示潔樹而期衝→業或已畢或棄。察 git log 為近活。
開各衝檔尋衝標:
<<<<<<< HEAD
// Your current branch's version
const result = calculateWeightedMean(data, weights);
=======
// Incoming branch's version
const result = computeWeightedAverage(data, weights);
>>>>>>> feature/rename-functions
<<<<<<< HEAD 至 =======:今枝(或汝改基所至枝)======= 至 >>>>>>>:來變(合枝或施提交)得:各衝檔含一或多塊有 <<<<<<<、=======、>>>>>>> 標。
敗:無標而檔示衝→衝或為二進檔或刪對改之衝。察 git diff --name-only --diff-filter=U 為全列。
手合(最常):編檔合二變、後除諸衝標。
受我(留今枝版):
# For a single file
git checkout --ours path/to/file.R
git add path/to/file.R
# For all conflicts
git checkout --ours .
git add -A
受彼(留來枝版):
# For a single file
git checkout --theirs path/to/file.R
git add path/to/file.R
# For all conflicts
git checkout --theirs .
git add -A
得:解後、檔含正合容、無餘衝標。
敗:擇誤側→自合基重讀衝版。合中、git checkout -m path/to/file 重建衝標以再試。
各衝檔編後:
# Stage the resolved file
git add path/to/resolved-file.R
# Check remaining conflicts
git status
「Unmerged paths」下諸檔皆復。
得:諸檔自「Unmerged paths」移至「Changes to be committed」。任檔無餘衝標。
敗:git add 敗或標餘→重開檔、確 <<<<<<<、=======、>>>>>>> 諸行皆除。
諸衝既解:
為合:
git commit
# Git auto-populates the merge commit message
為改基:
git rebase --continue
# May encounter more conflicts on subsequent commits — repeat steps 2-4
為 cherry-pick:
git cherry-pick --continue
為 stash pop:
# Stash pop conflicts don't need a continue — just commit or reset
git add .
git commit -m "Apply stashed changes with conflict resolution"
得:業畢。git status 示潔工樹(或改基中移至次提交)。
敗:續命敗→察 git status 為餘未解檔。諸衝必解乃可續。
解過複或法誤→安棄:
# Abort merge
git merge --abort
# Abort rebase
git rebase --abort
# Abort cherry-pick
git cherry-pick --abort
得:庫返業始前態。無數失。
敗:棄敗(罕)→察 git reflog 尋業前提交、git reset --hard <commit> 復之。慎用——此棄未提交變。
業畢後:
# Verify clean working tree
git status
# Check that the merge/rebase result is correct
git log --oneline -5
git diff HEAD~1
# Run tests to confirm nothing is broken
# (language-specific: devtools::test(), npm test, cargo test, etc.)
得:潔工樹、正合史、測過。
敗:解後測敗→合或引邏輯錯雖語衝解。慎審 diff 乃修。
<<<<<<<、=======、>>>>>>>)餘git status 示潔工樹git log 正--ours 或 --theirs 棄他側全。唯確一版全正乃用--amend 除非該步明命。用 git rebase --continue 代git rebase --abort 與 git merge --abort 棄諸解工。唯欲重始乃棄commit-changes - 衝解後提交manage-git-branches - 致衝之枝流configure-git-repository - 庫設與合策