亚洲欧美精品沙发,日韩在线精品视频,亚洲Av每日更新在线观看,亚洲国产另类一区在线5

<pre id="hdphd"></pre>

  • <div id="hdphd"><small id="hdphd"></small></div>
      學(xué)習(xí)啦>學(xué)習(xí)電腦>操作系統(tǒng)>Linux教程>

      Linux下使用git命令及github項目教程

      時間: 志藝942 分享

        隨著Internet網(wǎng)絡(luò)的普及,Linux操作系統(tǒng)正在各個方面得到廣泛的應(yīng)用。Linux操作系統(tǒng)在服務(wù)器、嵌入式等方面已經(jīng)取得不俗的成績,在桌面系統(tǒng)方面,也逐漸受到歡迎。接下來是小編為大家收集的Linux下使用git命令及github項目教程,希望能幫到大家。

        Linux下使用git命令及github項目教程

        在linux下搭建git環(huán)境

        1、創(chuàng)建Github賬號,https://github.com

        2、Linux創(chuàng)建SSH密鑰:

        [plain] view plain copyssh-keygen ##一直默認(rèn)就可以了

        3、將公鑰加入到Github賬戶信息Account Settings->SSH Key

        4、測試驗證是否成功。

        [plain] view plain copyssh -T git@github.com

        Hi someone! You've successfully authenticated, but GitHub does not provide shell access.

        同步github到本地

        1、復(fù)制項目到本地:

        [plain] view plain copygit clone git://github.com:xxxx/test.git ##以gitreadonly方式克隆到本地,只可以讀

        git clone git@github.com:xxx/test.git ##以SSH方式克隆到本地,可以讀寫

        git clone https://github.com/xxx/test.git ##以https方式克隆到本地,可以讀寫

        git fetch git@github.com:xxx/xxx.git ##獲取到本地但不合并

        git pull git@github.com:xxx/xxx.git ##獲取并合并內(nèi)容到本地

        本地提交項目到github

        1、本地配置

        [plain] view plain copygit config --global user.name 'onovps'

        git config --global user.email 'onovps@onovps.com' #全局聯(lián)系方式,可選

        2、新建Git項目并提交到Github。

        [plain] view plain copymkdir testdir & cd testdir

        touch README.md

        git init #初始化一個本地庫

        git add README.md #添加文件到本地倉庫

        git rm README.md #本地倒庫內(nèi)刪除

        git commit -m "first commit" #提交到本地庫并備注,此時變更仍在本地。

        git commit -a ##自動更新變化的文件,a可以理解為auto

        git remote add xxx git@github.com:xxx/xxx.git #增加一個遠(yuǎn)程服務(wù)器的別名。

        git remote rm xxx ##刪除遠(yuǎn)程版本庫的別名

        git push -u remotename master #將本地文件提交到Github的remoname版本庫中。此時才更新了本地變更到github服務(wù)上。

        分支版本操作

        1、創(chuàng)建和合并分支

        [plain] view plain copygit branch #顯示當(dāng)前分支是master

        git branch new-feature #創(chuàng)建分支

        git checkout new-feature #切換到新分支

        vi page_cache.inc.php

        git add page_cache.inc.php

        git commit -a -m "added initial version of page cache"

        git push origin new-feature ##把分支提交到遠(yuǎn)程服務(wù)器,只是把分支結(jié)構(gòu)和內(nèi)容提交到遠(yuǎn)程,并沒有發(fā)生和主干的合并行為。

        2、如果new-feature分支成熟了,覺得有必要合并進(jìn)master

        [plain] view plain copygit checkout master #切換到新主干

        git merge new-feature ##把分支合并到主干

        git branch #顯示當(dāng)前分支是master

        git push #此時主干中也合并了new-feature的代碼


      看了“Linux下使用git命令及github項目教程”還想看:

      1.git每次提交都要輸入密碼怎么辦

      2.Linux系統(tǒng)上怎樣安裝Git

      3.CentOS系統(tǒng)怎樣搭建Git版本控制服務(wù)器

      4.Ubuntu系統(tǒng)git每次提交都要輸入密碼如何解決

      2805684