github linux 命令列操作執行個體

來源:互聯網
上載者:User

標籤:

繼續整理一下linux 下面使用命令列操作執行個體

首先建立檔案目錄 然後 執行 git clone 操作

[email protected]:~/案頭$ cd test/[email protected]:~/案頭/test$ git clone https://github.com/timelessz/TESTDEMO.git
正複製到 ‘TESTDEMO‘...
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (3/3), done.

下面是執行 git --help 操作

[email protected]:~/案頭/test$ git --help用法:git [--version] [--help] [-C <path>] [-c name=value]           [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]           <command> [<args>]最常用的 git 命令有:   add        添加檔案內容至索引   bisect     通過二分尋找定位引入 bug 的變更   branch     列出、建立或刪除分支   checkout   檢出一個分支或路徑到工作區   clone      複製一個版本庫到一個新目錄   commit     記錄變更到版本庫   diff       顯示提交之間、提交和工作區之間等的差異   fetch      從另外一個版本庫下載對象和引用   grep       輸出和模式比對的行   init       建立一個空的 Git 版本庫或重新初始化一個已存在的版本庫   log        顯示提交日誌   merge      合并兩個或更多開發曆史   mv         移動或重新命名一個檔案、目錄或符號連結   pull       擷取並整合另外的版本庫或一個本地分支   push       更新遠端參照和相關的對象   rebase     本地提交轉移至更新後的上遊分支中   reset      重設當前HEAD到指定狀態   rm         從工作區和索引中刪除檔案   show       顯示各種類型的對象   status     顯示工作區狀態   tag        建立、列出、刪除或校正一個GPG簽名的 tag 對象

測試建立一個檔案然後上傳

[email protected]:/home/timeless/案頭/test/TESTDEMO# vi demo[email protected]:/home/timeless/案頭/test/TESTDEMO# git add ./*[email protected]:/home/timeless/案頭/test/TESTDEMO# git commit*** Please tell me who you are.Run  git config --global user.email "[email protected]"  git config --global user.name "Your Name"to set your account‘s default identity.Omit --global to set the identity only in this repository.fatal: unable to auto-detect email address (got ‘[email protected](none)‘)

遇到錯誤,是沒有運行git config --global user.email "[email protected]"   來表明我的身份。

運行  該語句便可。

[email protected]Notebook-PC:/home/timeless/案頭/test/TESTDEMO# git config --global user.email "[email protected]"[email protected]:/home/timeless/案頭/test/TESTDEMO# git  commit -a  -m 第一次提交

 

git commit 巨集指令引數:
用法:git commit [選項] [--] <路徑規則>... -q, --quiet 提交成功後不顯示概述資訊 -v, --verbose 在提交說明模板裡顯示差異提交說明選項 -F, --file <檔案> 從檔案中讀取提交說明 --author <作者> 提交時覆蓋作者 --date <日期> 提交時覆蓋日期 -m, --message <說明> 提交說明 -c, --reedit-message <提交> 重用並編輯指定提交的提交說明 -C, --reuse-message <提交> 重用指定提交的提交說明 --fixup <提交> 使用 autosquash 格式的提交說明用以修正指定的提交 --squash <提交> 使用 autosquash 格式的提交說明用以壓縮至指定的提交 --reset-author 現在將該提交的作者改為我(和 -C/-c/--amend 參數共用) -s, --signoff 添加 Signed-off-by: 簽名 -t, --template <檔案> 使用指定的模板檔案 -e, --edit 強制編輯提交 --cleanup <default> 設定如何刪除提交說明裡的空格和#注釋 --status 在提交說明模板裡包含狀態資訊 -S, --gpg-sign[=<key id>] GPG 提交簽名提交內容選項 -a, --all 提交所有改動的檔案 -i, --include 添加指定的檔案到索引區等待提交 --interactive 互動式添加檔案 -p, --patch 互動式添加變更 -o, --only 只提交指定的檔案 -n, --no-verify 繞過 pre-commit 鉤子 --dry-run 顯示將要提交的內容 --short 以簡潔的格式顯示狀態 --branch 顯示分支資訊 --porcelain 機器可讀的輸出 --long 以長格式顯示狀態(預設) -z, --null 條目以NUL字元結尾 --amend 修改先前的提交 --no-post-rewrite 繞過 post-rewrite 鉤子 -u, --untracked-files[=<模式>] 顯示未跟蹤的檔案,“模式”的選擇性參數:all、normal、no。(預設:all)

 執行git push 推送

[email protected]:/home/timeless/案頭/test/TESTDEMO# git pushUsername for ‘https://github.com‘: timelesszPassword for ‘https://[email protected]‘: Counting objects: 4, done.Delta compression using up to 4 threads.Compressing objects: 100% (2/2), done.Writing objects: 100% (3/3), 305 bytes | 0 bytes/s, done.Total 3 (delta 0), reused 0 (delta 0)To https://github.com/timelessz/TESTDEMO.git   a01a7c2..b15b255  master -> master

 

 異常資訊處理

執行個體  新開一個linux 命令列執行個體  

建立檔案夾  執行 git clone  檔案 url

[email protected]:~/案頭/demo$ git clone https://github.com/timelessz/TESTDEMO.git正複製到 ‘TESTDEMO‘...remote: Counting objects: 6, done.remote: Compressing objects: 100% (3/3), done.remote: Total 6 (delta 0), reused 3 (delta 0), pack-reused 0Unpacking objects: 100% (6/6), done.檢查串連... 完成。[email protected]:~/案頭/demo$ lsTESTDEMO

 

新的會話中修改檔案

[email protected]:~/案頭/demo/TESTDEMO$ lsdemo  README.md
[email protected]:~/案頭/demo/TESTDEMO$ vi demo
[email protected]:~/案頭/demo/TESTDEMO$ git add .
[email protected]:~/案頭/demo/TESTDEMO$ git commit -a -m "第二次測試"
[master 6b98505] 第二次測試
 1 file changed, 1 insertion(+), 1 deletion(-)
[email protected]ion-g4-Notebook-PC:~/案頭/demo/TESTDEMO$ git push

 

github 異常處理:

[email protected]:/home/timeless/案頭/test/TESTDEMO# vi demo     //修改本地檔案 同時提交 [email protected]:/home/timeless/案頭/test/TESTDEMO# git add . [email protected]:/home/timeless/案頭/test/TESTDEMO# git commit -a -m "趙興壯測試衝突異常"   //提交檔案發現問題[master d948414] 趙興壯測試衝突異常 1 file changed, 1 insertion(+), 1 deletion(-)[email protected]:/home/timeless/案頭/test/TESTDEMO# git pushUsername for ‘https://github.com‘: timelesszPassword for ‘https://[email protected]‘: To https://github.com/timelessz/TESTDEMO.git ! [rejected]        master -> master (fetch first)error: 無法推送一些引用到 ‘https://github.com/timelessz/TESTDEMO.git‘    //版本異常提示:更新被拒絕,因為遠程版本庫包含您本地尚不存在的提交。這通常是因為另外提示:一個版本庫已向該引用進行了推送。再次推送前,您可能需要先整合遠程變更提示:(如 ‘git pull ...‘)。提示:詳見 ‘git push --help‘ 中的 ‘Note about fast-forwards‘ 小節。[email protected]:/home/timeless/案頭/test/TESTDEMO# git pull    //首先pull 下來解決問題remote: Counting objects: 3, done.remote: Compressing objects: 100% (2/2), done.remote: Total 3 (delta 0), reused 3 (delta 0), pack-reused 0Unpacking objects: 100% (3/3), done.來自 https://github.com/timelessz/TESTDEMO   b15b255..6b98505  master     -> origin/master自動合并 demo衝突(內容):合并衝突於 demo自動合并失敗,修正衝突然後提交修正的結果。[email protected]:/home/timeless/案頭/test/TESTDEMO# git diffdiff --cc demoindex 8677aea,fc19e2b..0000000--- a/demo+++ b/demo@@@ -1,1 -1,1 +1,5 @@@++<<<<<<< HEAD +趙興壯測試實現   異常的版本++=======+ 趙興壯測試實現   我不喜歡檔案++>>>>>>> 6b98505ba81551d18ad01e82f59dc7ae3e6f1d5e[email protected]:/home/timeless/案頭/test/TESTDEMO# vi demo   //修改檔案處理完 版本之後[email protected]:/home/timeless/案頭/test/TESTDEMO# git add .[email protected]:/home/timeless/案頭/test/TESTDEMO# git commit -a -m "處理衝突之後"[master f7a190d] 處理衝突之後[email protected]:/home/timeless/案頭/test/TESTDEMO# git pushUsername for ‘https://github.com‘: timelesszPassword for ‘https://[email protected]‘: Counting objects: 8, done.Delta compression using up to 4 threads.Compressing objects: 100% (3/3), done.Writing objects: 100% (4/4), 534 bytes | 0 bytes/s, done.Total 4 (delta 0), reused 0 (delta 0)To https://github.com/timelessz/TESTDEMO.git   6b98505..f7a190d  master -> master

異常處理完成。

論壇收集別人對於使用github經驗:

  • 多用工具,少用命令列,除非迫不得已使用linux伺服器。
  • 提交前首先diff 代碼一下,一面出現錯誤。
  • 下班回家之前整理好自己的工作區,第二天上班節省時間,防止代碼混亂。
  • 並行的項目,比如好多模組需要一塊開發,使用分支開發,有效減少項目風險。
  • push 時候遇到衝突,弄明白衝突的原因,不要求起別人代碼。
  • 產品發布之後記得打bug,方便將來拉分支修改bug。

 

github linux 命令列操作執行個體

聯繫我們

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