github快速入門(一)


一、github介紹

  git是一款非常知名的代碼托管工具。當然現在有了github for windows版本(類似於 svn tortoise).

 

  GitHub for Windows 是一個 Metro 風格應用程序,集成了自包含版本的 Git,bash 命令行 shell,PowerShell 的 posh-git 擴展。GitHub 為 Windows 用戶提供了一個基本的圖形前端去處理大部分常用版本控制任務,可以創建版本庫,向本地版本庫遞交補丁,在本地和遠程版本庫之間同步。微軟也通過CodePlex向開發者提供 git 版本控制系統,而 GitHub 創造了一個更具有吸引力的 Windows 版本。

當然,你可以使用這個客戶端代替繁瑣的命令。可以使用git bash 命令行shell 下載 github for windows

安裝使用,這里就不介紹了。具體可以參考 http://www.ihref.com/read-16514.html 。本文不講如何使用客戶端,而是教你學會用命令搭建,包括ssh key生成

 

二、github管理界面 官網

1、注冊 : 記住郵箱

2、git初始化賬戶|密碼

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

3、隨便找一個目錄,右擊 git bash(前提你要安裝過github for windows), 生成ssh key秘鑰

ssh-keygen -t rsa -C"你的郵箱"

如果成功的話,會在~/ 目錄下創建 .ssh 目錄

進入~/.ssh/目錄 vim  id_rsa.pub 。將 id_rsa.pub的內容copy

4、進入github個人設置頁面。Settings -- 》 ssh and GPG keys --》 new ssh key --> 將 id_rsa.pub的內容copy至key即可

 

 

 5、驗證ssh key 是否生效

ssh -T git@github.com

結果可能會出現如下

The authenticity of host 'github.com (192.30.253.112)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)?

輸入 yes

Warning: Permanently added 'github.com,192.30.253.112' (RSA) to the list of known hosts.
Hi xpw! You've successfully authenticated, but GitHub does not provide shell access.

這就代表成功了

 

 

6、馬上擼一發。看看github是怎么托管代碼的

①、創建倉庫 repository

 

②、將遠程分支拉取下來

 git clone "https://github.com/xpw/gitDemo.git"

結果

Cloning into 'gitDemo'...
warning: You appear to have cloned an empty repository.
Checking connectivity... done.

 

 然后進入工程目錄gitDemo目錄下

隨便加個文件 test.txt , vi test.txt 打開后編輯hi,git !

提交code到本地緩存區 git commit a -m'注釋說明'

提交到遠程github上,git push origin master。這時會要求你輸入用戶名(github用戶名)、密碼(github注冊的密碼)

③、我們在github上就可以看到剛才提交的code記錄

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM