Ubuntu下git使用教程

2021-07-09 06:18:07 字數 2591 閱讀 1966

sudo apt-get install git

github用到了ssh,需要在shell裡檢查是否連線到github:

willard@willard-pc~/github/blog $ ssh -t [email protected]

hi willard-yuan! you've successfully authenticated, but github does not provide shell access.

上面表明新增成功。

比較常見的將遠端版本庫中的**clone到本地的方式如下:

git clone [email protected]:willard-yuan/blog.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 [email protected]: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 ch07

1 file changed, 4 insertions(+)

willard@willard-pc~/github/pcvwithpython $ git remote -v

origin [email protected]:willard-yuan/pcvwithpython.git (fetch)

origin [email protected]: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 '[email protected]:willard-yuan/pcvwithpython.git

暫時就這樣吧。

reference:

[1].ubuntu下github的使用

[2].在ubuntu下配置舒服的python開發環境

from: 

linux 下git使用教程

新增所有新增檔案 git add 提交所有修改,包括刪除,新增,修改 git add a git add all 檢視狀態 git status 新增乙個檔案 git add readme git commit m add readme git push u origin master 刪除檔案 g...

Ubuntu下git的使用

ubuntu下git的使用 安裝 sudo apt get install git基本使用 以使用blog倉庫為例 在github上新建乙個倉庫 blog 本地git操作 初始化配置 git init blog git config global user.name uesrname git con...

ubuntu下git安裝及使用

其實,好幾個月前,就已經安裝好了,可是一直擱置在那兒,所以密碼等一些其它細節都忘的差不多了,所以今天就重新部署了一下,並開始積極使用。1,git 安裝 sudo apt get install git core openssh server openssh client sudo apt get i...