安裝git,使用命令yum install git,等待安裝完成
確保有一個github賬號,新建一個倉庫,就叫test吧,待會進行連接
安裝好git後,需要知道rsa密匙,才能和github進行遠程連接。
生成ssh key,使用命令 “ssh-keygen -t rsa -C “your mail”,your_email是你的郵箱地址
使用命令cd `/.ssh 找到剛纔生成的密匙,複製密匙(注意是pub那個公匙)
回到github,進入Account Settings,左邊選擇SSH Keys,Add SSH Key,名字隨便填填,粘貼密匙。
測試ssh key是否成功,使用命令“ssh -T [email protected]”,如果出現You’ve successfully authenticated, but GitHub does not provide shell access 。這就表示已成功連上github。
配置Git的配置文件,username和email
使用命令:git config --global user.name "your name" //配置用戶名
使用命令: git config --global user.name "your email"//配置email地址
這樣完成了一半了,接下來進行本地庫和遠程庫的操作
在你想要作爲本地庫的地方新建一個目錄,如test,建好後進入目錄,輸入命令git init 把它作爲本地庫
使用命令 git remote add origin [email protected]:github用戶名/倉庫名.git 鏈接本地和遠程庫
在當前目錄中新建一個文件。使用 git add 文件名 把文件添加到本地庫
使用命令
git commit -m “對這次的提交作說明”
最後把本地倉庫origin提交到遠程的GitHub倉庫,使用命令 git push origin master
然後就可以在github看到你推送的文件了。