目錄
兩處的代碼git合並,需要解決產生的沖突,我現在初步接觸merge的問題,暫且這樣記錄。
git pull遇到錯誤:error: Your local changes to the following files would be overwritten by merge:
- 保留原來的改動,先將遠端代碼pull下來然后應用原來的改動
git stash git pull git stash pop
- 不保留原來的改動,直接回退到上一版本再pull
git reset --hard git pull
fatal: refusing to merge unrelated histories
在操作命令后面加上--allow-unrelated-histories
Git『Everything up-to-date』問題解決
本來有要提交的代碼但卻說已經是最新版本了,解決方法是新建一個newbranch分支,將當前分支truebranch要提交的內容先提交到newbranch上,將新分支上的內容合並到truebranch上,再推truebranch的內容到遠端倉庫,最后刪掉新分支。命令:
git branch
git branch newbranch
git branch
git checkout newbranch
git branch
git add .
git commit -m 'message'
git checkout truebranch
git merge newbranch
git diff
git push origin truebranch
git branch -D newbranch
新添的gitignore項在commit中生效
git rm -r --cached .
本文創建於2020-10-09 11:01,修改於2021年6月17日14點28分