git 提交報錯 cannot do a partial commit during a merge


git 提交報錯 cannot do a partial commit during a merge

 

在提交代碼時,有時會遇到這樣的問題。
其實是合並代碼時,你可能遇到有代碼沖突了。
同時,你發現別的地方有bug,然后你就把那個bug給修復了。
然后再git commit -am”時,就會發生cannot do a partial commit during a merge這樣的錯誤;

解決方法:
把你修改的非沖突代碼給撤銷了。然后再git commit即可。

然后針對有bug的代碼,等上一次合並代碼git push成功后,再修改代碼,再commit即可;

 

或者,不提交全部,吧合並的先提交,那么可以通過添加 -i 選項

git commit file/to/path -i -m "merge"

 

Git創建遠程分支

現在我在master分支上,工作目標是干凈的,也沒有需要commit的:

$ git branch
* master
release

$ git status

On branch master
Your branch is up-to-date with 'origin/master'. nothing to commit, working directory clean 

新建遠程分支
新建一個本地分支:

$ git checkout -b localbranch

查看一下現在的分支狀態:

$ git branch

*localbranch
 master
 release

星號(*)表示當前所在分支。現在的狀態是成功創建的新的分支並且已經切換到新分支上。

把新建的本地分支push到遠程服務器,遠程分支與本地分支同名(當然可以隨意起名):

$ git push origin localbranch:localbranch

使用git branch -a查看所有分支,會看到remotes/origin/localbranch這個遠程分支,說明新建遠程分支成功。

刪除遠程分支
我比較喜歡的簡單方式,推送一個空分支到遠程分支,其實就相當於刪除遠程分支:

$ git push origin :localbranch
也可以使用:

$ git push origin --delete localbranch
這兩種方式都可以刪除指定的遠程分支

git使用文檔 - git創建遠程分支
https://www.showdoc.cc/xuliulei?page_id=1565517113560223


一個小時學會Git

Git創建本地分支並關聯遠程分支

在github上面部署預覽你的React項目(搭建博客)

對於上傳到master分支不能正常訪問react項目的app,經過測試發現需要修改所有資源的絕對路徑為相當路徑,即把所有引用資源文件的地方‘/。。。’前面的‘/’去掉就可以了,比如index.html:

<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="icon" href="/exchange/favicon.ico"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="theme-color" content="#000000"/>
<meta name="description" content="Web site created using create-react-app"/>
<link rel="apple-touch-icon" href="logo192.png"/>
<link rel="manifest" href="/exchange/manifest.json"/>
<title>React App</title>
<link href="/exchange/static/css/main.9fc4fdf3.chunk.css" rel="stylesheet">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script>。。。。</script>
<script src="/exchange/static/js/2.fc1fe354.chunk.js"></script>
<script src="/exchange/static/js/main.6bb9b3fc.chunk.js"></script>
</body>
</html>
上面文件中標注的"/..."改為"...",就可以正常訪問index.html。
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<link rel="icon" href="exchange/favicon.ico"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="theme-color" content="#000000"/>
<meta name="description" content="Web site created using create-react-app"/>
<link rel="apple-touch-icon" href="logo192.png"/>
<link rel="manifest" href="/exchange/manifest.json"/>
<title>React App</title>
<link href="exchange/static/css/main.9fc4fdf3.chunk.css" rel="stylesheet">
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<script>。。。。</script>
<script src="exchange/static/js/2.fc1fe354.chunk.js"></script>
<script src="exchange/static/js/main.6bb9b3fc.chunk.js"></script>
</body>
</html>

這個可能是github的bug.
因為上傳到非master分支就可以。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM