idea中新建git分支,並提交到遠程github


一、IDEA連接github,創建本地倉庫和遠程github倉庫

1. idea登錄github ,參考:使用IntelliJ IDEA如何連接Github並上傳項目

2. idea創建本地倉庫,連接github遠程倉庫。參考:idea中將項目與github關聯

二、IDEA中創建本地分支,並提交到遠程倉庫分支中

1. IDEA中創建本地分支。參考:IDEA本地新建分支並push到遠程創建分支

2. 當將本地分支提交到遠程分支是出現提交被拒絕錯誤“Push rejected Push to origin/dev-01 was rejected”。

參考:Git錯誤信息解決辦法:Push rejected: Push to origin/platformDev was rejected

 

 大概步驟:在idea中的Terminal中進入到提交項目中,依次輸入一下命令。注:dev-01是我新建分支的名字。完成步驟后再次push一下,可能需要merge一下

E:\hahaha\study-cloud>git checkout -b dev-01
fatal: A branch named 'dev-01' already exists.

E:\hahaha\study-cloud>git branch -aa
* dev-01
  master
  remotes/origin/dev-01
  remotes/origin/master

E:\hahaha\study-cloud>git branch --set-upstream-to origin/dev-01 dev-01
Branch 'dev-01' set up to track remote branch 'dev-01' from 'origin'.

  

 3. 如果出現一下問題一般是網絡問題,重現連接其他網絡試試。

Push failed
            Invocation failed Server returned invalid Response.
            java.lang.RuntimeException: Invocation failed Server returned invalid Response.
            at org.jetbrains.git4idea.http.GitAskPassXmlRpcClient.askUsername(GitAskPassXmlRpcClient.java:50)
            at org.jetbrains.git4idea.http.GitAskPassApp.main(GitAskPassApp.java:64)
            Caused by: java.io.IOException: Server returned invalid Response.
            at org.apache.xmlrpc.LiteXmlRpcTransport.sendRequest(LiteXmlRpcTransport.java:242)
            at org.apache.xmlrpc.LiteXmlRpcTransport.sendXmlRpc(LiteXmlRpcTransport.java:90)
            at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:194)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:185)
            at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:178)
            at org.jetbrains.git4idea.http.GitAskPassXmlRpcClient.askUsername(GitAskPassXmlRpcClient.java:47)
            ... 1 more
            remote: No anonymous write access.

  三、idea中連接開源的git項目,在本地修改上傳到開源github中

1. 先用git 命令從遠程倉庫克隆下項目代碼到本地的文件夾

2. 在文件夾中用idea打開該項目,檢查版本控制Remote中有沒有加入該項目的git地址,檢查方式:VCS>Git>Remotes,打開后檢查有沒有gi的url地址信息,如果沒有,點加號,添加項目的git地址,以及名稱,名稱隨意填一個即可。

 

3.最后選擇代碼,commit,push....。也可在左下角的Git控制欄中檢查設置相關的git信息,可以在這里切換多個遠程分支。

 4.  idea中設置多個遠程remote倉庫,以及git的使用

參考:

IDEA中一個工程多個模塊(module)分別提交到不同的git服務器

Idea中關於Git的使用

詳解IDEA中的Git操作

IDEA上Git操作


免責聲明!

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



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