git命令列常用操作及在linux下push到github項目中遇到的問題

來源:互聯網
上載者:User
在github下面整理了下幾個測試專案,打算將python相關程式放到linux下面維護。於是學習了下git命令列工具

git add  #將檔案放入本地庫

git commit -m " log message" -a  #提交修改到本地庫  -a 代表所有,也可後跟檔案名稱或列表選擇性提交

git log  #查看日誌資訊  git log -n3  查看最近3條日誌

git status  #查看本地檔案狀態

git branch #列出本地分支

git branch -r  #列出遠端分支

git branch -a #本地遠程分支都本顯示出來

git diff  #查看檔案修改 (還沒有用到)

git show #可以看到提交的更多資訊 

git show 6eb2c1a15a2f52a147cf2d491fdd1d113d218a43 #(提交號) 看到此次提交都修改了哪些內容等

 

當我們需要將本地庫提交到遠端伺服器時,需要加一個遠端點 也可在.git/confige中配置

git remote add 遠端點名 http://github.com/<username>/<reponame>.git  #添加一個遠程分支

git push origin master push #push分支到遠程

git remote set-url  #修改遠程分支的url地址 , 如:由http修改為ssh的地址

 

在git push過程中出現問題:

由於用的是https方式clone的,聽網上說linux下只能用ssh的方式push,於是利用git remote set-url sshurl改為ssh地址,或者直接在.git/confige下面修改

又學習了下ssh與github的如何建立的。參考地址:https://help.github.com/articles/generating-ssh-keys

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.