Ubuntu下git使用教程
生活随笔
收集整理的這篇文章主要介紹了
Ubuntu下git使用教程
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
安裝git
sudo apt-get install git檢查SSH
GitHub用到了SSH,需要在shell里檢查是否連接到GitHub:
willard@willard-PC~/github/blog $ ssh -T git@github.com Hi willard-yuan! You've successfully authenticated, but GitHub does not provide shell access.上面表明添加成功。
克隆rep
比較常見的將遠程版本庫中的代碼clone到本地的方式如下:
git clone git@github.com:willard-yuan/blog.git其他常用Git命令
git init # 初始化本地Git版本庫 git add # 暫存文件,如果使用.表示當前目錄及其子目錄 git commit -m “first commit” # 提交,-m選項后跟內容為提交所用的注釋 git remote -v # 查看當前項目遠程連接的是哪個版本庫地址 git push origin master # 將本地項目提交到遠程版本庫 git fetch origin # 取得遠程更新(到origin/master),但還沒有合并 git merge origin/master # 把更新的內容(origin/master)合并到本地分支(master) git pull origin master # 相當于fetch和merge的合并,但分步操作更保險 git branch -r #查看分支 git checkout origin/master(gh-pages) #切換分支 git push origin :branch_you_want_to_delete #刪除遠程分支(注意空格,把一個空的branch賦值給已有的branch,這樣就刪除了)示例
willard@willard-PC~/github $ git clone git@github.com:willard-yuan/pcvwithpython.git Cloning into 'pcvwithpython'... remote: Reusing existing pack: 1960, done. remote: Total 1960 (delta 0), reused 0 (delta 0) Receiving objects: 100% (1960/1960), 58.58 MiB | 2.10 MiB/s, done. Resolving deltas: 100% (671/671), done. Checking connectivity... done.克隆下來后,便可以對項目的文件進行修改添加,修改添加完成后,提交到遠程版本控制庫:
willard@willard-PC~/github/pcvwithpython $ git add . willard@willard-PC~/github/pcvwithpython $ git commit -m "update content in ch07"[gh-pages 221c8bc] update content in ch071 file changed, 4 insertions(+)在push之前,我們先來查看一下當前項目遠程連接的是哪個版本庫地址:
willard@willard-PC~/github/pcvwithpython $ git remote -v origin git@github.com:willard-yuan/pcvwithpython.git (fetch) origin git@github.com:willard-yuan/pcvwithpython.git (push)然后push:
git push注意,這里本小子并沒有用git push origin master,用該命令,出現下面錯誤:
willard@willard-PC~/github/pcvwithpython $ git push origin master Warning: Permanently added the RSA host key for IP address '2001:778:0:ffff:64:0:c01e:fc83' to the list of known hosts. error: src refspec master does not match any. error: failed to push some refs to 'git@github.com:willard-yuan/pcvwithpython.git暫時就這樣吧。
Reference:
[1].Ubuntu下GitHub的使用
[2].在Ubuntu下配置舒服的Python開發環境
from:?http://yongyuan.name/blog/the-trick-of-using-git.html
總結
以上是生活随笔為你收集整理的Ubuntu下git使用教程的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 基于内容的图像检索 Database f
- 下一篇: ubuntu18.04安装pycharm