github常用指令

2021-06-14 10:25:55 字數 1406 閱讀 4122

總結一下ubuntu下github常用的命令,設定部分跳過,假設repository的名字叫hello-world:

1.建立乙個新的repository:

先在github上建立並寫好相關名字,描述。

$cd ~/hello-world        //到hello-world目錄

$git init                     //初始化

$git add .                   //把所有檔案加入到索引(不想把所有檔案加入,可以用gitignore或add 具體檔案)

$git commit               //提交到本地倉庫,然後會填寫更新日誌( -m 「更新日誌」也可)

$git remote add origin [email protected]:wadeleng/hello-world.git        //增加到remote

$git push origin master    //push到github上

2.更新專案(新加了檔案):

$cd ~/hello-world

$git add .                  //這樣可以自動判斷新加了哪些檔案,或者手動加入檔案名字

$git commit              //提交到本地倉庫

$git push origin master    //不是新建立的,不用再add 到remote上了

3.更新專案(沒新加檔案,只有刪除或者修改檔案):

$cd ~/hello-world

$git commit -a          //記錄刪除或修改了哪些檔案

$git push origin master  //提交到github

4.忽略一些檔案,比如*.o等:

$cd ~/hello-world

$vim .gitignore     //把檔案型別加入到.gitignore中,儲存

然後就可以git add . 能自動過濾這種檔案

5.clone**到本地:

$git clone [email protected]:wadeleng/hello-world.git

假如本地已經存在了**,而倉庫裡有更新,把更改的合併到本地的專案:

$git fetch origin    //獲取遠端更新

$git merge origin/master //把更新的內容合併到本地分支

6.撤銷

$git reset

7.刪除

$git rm  * // 不是用rm

乙個中文git手冊:

Github常用指令

名稱 作用cd 進入到乙個目錄 pwd顯示當前所在的目錄 ls將目錄裡的每個檔案列出來 git init 把這個目錄變成可管理的空倉庫 git status 檢視當前倉庫的狀態 git add 往倉庫裡加檔案 git rm cached 刪除倉庫中不需要的東西 git commit 提交到倉庫 gi...

Github常用指令

ssh方法git init ssh keygen t rsa c yourname 輸入路徑後開啟id rsa.pub複製到倉庫 setting deploy keys,allow write access記得打勾 git remode add 遠端倉庫命名 ssh 例如 git remote ad...

GitHub常用指令 Tag

tag 同大多數 vcs 一樣,git 也可以對某一時間點上的版本打上標籤。人們在發布某個軟體版本 比如 v1.0 等等 的時候,經常這麼做。本節我們一起來學習如何列出所有可用的標籤,如何新建標籤,以及各種不同型別標籤之間的差別。列出現有標籤的命令非常簡單,直接執行git tag即可 git tag...