[英]git merge without merge conflicts from unrelated branch
我有一個在本地機器上損壞的 git 存儲庫。 為了解決我的問題,我刪除了本地機器上的 git 文件並運行git init
。 然后我運行git commit -m "fixing git"
。 我的fix_git分支有我的最新代碼,我想拉入我的遙控器並將其與我的develop
分支合並。 我繼續並重置了我的遠程來源。 然后我嘗試拉我的開發分支並收到以下錯誤
致命的:拒絕合並不相關的歷史
然后我嘗試了以下git pull origin cleanup --allow-unrelated-histories
它創建了許多合並沖突,以便能夠通過。 此外,我打算保留我在本地機器上所做的每一個更改。 我將如何修復它以便我的遙控器進行更改並保留我的歷史記錄?
定義:
(location alpha) is my local repo file path with my .git file that got corrupted
(location beta) is a new file path
並不是說這是最好的解決方案。 我花了4個小時才得出這個結論。
git clone
到與我的本地存儲庫(位置 alpha)分開的另一個位置(位置 beta)。git add .
和git commit -m "solving git problems"
git pull -f
我會這樣做:
git init .
git add .
git commit "what I want as latest"
git remote add some-remote url-to-repo-with-the-project
git fetch some-remote
git reset --soft some-remote/some-branch
# all changes are in index
git commit -m "Latest changes"
就是這樣。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.