java基礎---->git的使用(一)

來源:互聯網
上載者:User

標籤:說明   sdn   origin   force   csv   沒有   int   ref   osi   

  這裡面記錄一下git的使用,只是平時工作中遇到的一些問題的解決方案,不會涉及到git的一些基礎概念及說明。人的天性便是這般涼薄,只要拿更好的來換,一定捨得。

 

Git的一些使用一、在碼雲建立好倉庫之後,想把本地已經寫好的程式碼推送上去。

首先git init我們的項目:

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1$ git initInitialized empty Git repository in G:/Java/Go/program/2017-05-18/LearnPython1/.git/

 添加項目到本地的倉庫:

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)$ git add .

 提交代碼到本地倉庫:

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)$ git commit -m ‘commit python code‘[master (root-commit) 4408093] commit python code 110 files changed, 5905 insertions(+) create mode 100644 .idea/misc.xml create mode 100644 .idea/modules.xml create mode 100644 .idea/workspace.xml create mode 100644 LearnPython1.iml create mode 100644 datagram/connMysql.py create mode 100644 datagram/funUtils.py create mode 100644 datagram/huhx.py create mode 100644 file/bookdata.csv create mode 100644 file/huhx.png create mode 100644 file/huhx1.txt create mode 100644 file/huhx2.txt create mode 100644 file/log.txt create mode 100644 file/log1.txt create mode 100644 file/seach_button.png ......

與伺服器的分支建立聯絡:

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)$ git remote add origin https://gitee.com/huhx/pythonLearn.git

推送代碼到遠程倉庫:

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)$ git push -f origin masterCounting objects: 137, done.Delta compression using up to 4 threads.Compressing objects: 100% (130/130), done.Writing objects: 100% (137/137), 127.37 KiB | 1.46 MiB/s, done.Total 137 (delta 1), reused 0 (delta 0)To https://gitee.com/huhx/pythonLearn.git + 45c1fff...4408093 master -> master (forced update)

 注意上述的推送需要加-f參數,如果沒有添加的話。會有如下的錯誤提示

[email protected] MINGW64 /g/Java/Go/program/2017-05-18/LearnPython1 (master)$ git push origin masterTo https://gitee.com/huhx/pythonLearn.git ! [rejected]        master -> master (fetch first)error: failed to push some refs to ‘https://gitee.com/huhx/pythonLearn.git‘hint: Updates were rejected because the remote contains work that you dohint: not have locally. This is usually caused by another repository pushinghint: to the same ref. You may want to first integrate the remote changeshint: (e.g., ‘git pull ...‘) before pushing again.hint: See the ‘Note about fast-forwards‘ in ‘git push --help‘ for details.

 

二、建立分支的一些基礎操作,更新或者提交代碼

整個的一個流程,可以如下的方式:

建立開發分支:
  git checkout huhx-dev添加到git管理:
  git add .提交到huhx
-dev本地倉庫:
  git commit -m ‘code‘切換到master分支:
  git checkout master從遠程倉庫更新代碼:
  git pull合并huhx
-dev分支:
  git merge huhx-dev提交到本地的mater倉庫:
  git commit
-m ‘master commit‘將本地的master代碼提交到遠程:
  git push origin master

關於分支建立、查看可以參考部落格:http://blog.csdn.net/arkblue/article/details/9568249。

 

友情連結

 

java基礎---->git的使用(一)

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.