github簡單使用教程

2021-06-26 12:47:35 字數 1429 閱讀 4358

首先在本地建立ssh key;

$ ssh-keygen -t rsa -c "[email protected]"
後面的[email protected]改為你的郵箱,之後會要求確認路徑和輸入密碼,我們這使用預設的一路回車就行。成功的話會在~/下生成.ssh資料夾,進去,開啟id_rsa.pub,複製裡面的key。

回到github,進入account settings,左邊選擇ssh keys,add ssh key,title隨便填,貼上key。為了驗證是否成功,在git bash下輸入:

$ ssh -t [email protected]
如果是第一次的會提示是否continue,輸入yes就會看到:you've successfully authenticated, but github does not provide shell access 。這就表示已成功連上github。

接下來我們要做的就是把本地倉庫傳到github上去,在此之前還需要設定username和email,因為github每次commit都會記錄他們。

$ git config --global user.name "your name"$ git config --global user.email "[email protected]"
$ git remote add origin [email protected]:yourname/yourrepo.git
後面的yourname和yourrepo表示你再github的使用者名稱和剛才新建的倉庫,加完之後進入.git,開啟config,這裡會多出乙個remote 「origin」內容,這就是剛才新增的遠端位址,也可以直接修改config來配置遠端位址。

接下來在本地倉庫裡新增一些檔案,比如readme,

$ git add readme$ git commit -m "first commit"
上傳到github:

$ git push origin master
git push命令會將本地倉庫推送到遠端伺服器。

git pull命令則相反。

錯誤整理:

1.agent admitted failure to sign using the key.

permission denied (publickey).

fatal: the remote end hung up unexpectedly

執行 ssh-add

2.error: repository not found.

fatal: the remote end hung up unexpectedly

在github上建立個版本倉庫

GIThub簡單使用教程

github是乙個基於git的 託管平台,付費使用者可以建私人倉庫,我們一般的免費使用者只能使用公共倉庫,也就是 要公開。對於一般人來說公共倉庫就已經足夠了,而且我們也沒多少 來管理,o o 下面是我總結的一些簡單使用方法,供初學者參考。要想使用github第一步當然是註冊github賬號了。之後就...

github簡單使用教程

在文章中插入 總是出現git和後面的不在一行中的情況。試了很多種辦法,都沒有搞定,搞得我很無語。大家就湊合著看吧。如果哪位大神知道如何解決,還請不吝賜教啊!github是乙個基於git的 託管平台,付費使用者可以建私人倉庫,我們一般的免費使用者只能使用公共倉庫,也就是 要公開。對於一般人來說公共倉庫...

github簡單使用教程

github是乙個基於git的 託管平台,付費使用者可以建私人倉庫,我們一般的免費使用者只能使用公共倉庫,也就是 要公開。對於一般人來說公共倉庫就已經足夠了,而且我們也沒多少 來管理,o o 下面是我總結的一些簡單使用方法,供初學者參考。要想使用github第一步當然是註冊github賬號了。之後就...