git 和 github 在linux下的簡單使用

來源:互聯網
上載者:User

因為工作中用到 github 管理檔案,這裡簡單說說常用的功能和方法,歡迎大家補充。

一、建立一個新的項目

           登入www.github.com,點擊頁面右下角“New Repository”,

           (1)填寫項目資訊:project name: demo

           (2)點擊“Create Repository” 

         至此,完成了一個項目在github上的建立,注意,一個項目只能對應一個倉庫。

            git的初始設定

            git config --global user.name "Your Real Name"

            git config --global user.email you@email.address

二、建立本地新項目工作樹

          項目建立完成後,網站上有這麼幾行提示;

          mkdir    ~/demo          // 建一個demo檔案夾

          cd    ~/demo             

          touch README.md        //產生一個空檔案

          git init                                 //產生.git 檔案夾

          git add README.md      //添加README.md 到待上傳的檔案清單

          git commit -m "first commit"       // -m 參數以及後面的字串是添加說明。

          git remote add origin https://github.com/****/demo.git  //定義遠程伺服器別名origin ,其中****為申請的賬戶名

          git push -u origin master   //本地和遠程合并,本地預設分支為master

三、刪除伺服器上的檔案

          git rm 檔案名稱

          git commit -m “delete file” 

          git push

幾個可以查看repo狀態的工具

 git log #可以查看每次commit的改變

 git diff #可以查看最近一次改變的內容,加上參數可以看其它的改變並互相比較

 git show #可以看某次的變更

git status # 查看目前工作樹的狀態

暫時寫到這裡,後續會補充,更多內容請查看參考資料。

參考資料

http://www.cnblogs.com/fnng/archive/2012/01/07/2315685.html

     

相關文章

聯繫我們

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