Centos6.7或7.2系統中 github配置及基本使用
1.安裝
yum install git git-gui
2.生成密鑰對
ssh-keygen -t rsa -C "github郵箱地址"
1、首先要檢查key是不是已經存在,
2、打開一個終端,並輸入以下命令:
$ ls -al ~/.ssh
如果結果列表中包含以下文件, 則不需要在生成新的KEY, 可以直接使用。
id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub
3、如果不存在, 則需要創建新的Key來使用。
輸入下面的命令來生成key, 註意替換你自己的郵箱地址。
$ ssh-keygen -t rsa -C "[email protected]
# Creates a new ssh key using the provided email
Generating public/private rsa key pair.
Enter file in which to save the key (/your_home_path/.ssh/id_rsa):
4、這裏在提示你保存key的位置, 默認直接回車就可以。
Enter passphrase (empty for no passphrase):
當你看到這個的時候, 輸入你的密碼。
Enter same passphrase again:
再次輸入, 以確認密碼。
5、當以上步驟成功完成後, 你將看到類似與這樣的結果:
Your identification has been saved in /your_home_path/.ssh/id_rsa.
Your public key has been saved in /your_home_path/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db [email protected]
6、執行以下命令將KEY加入到ssh-agent:
$ eval "$(ssh-agent -s)"
# Agent pid 59566
$ ssh-add ~/.ssh/id_rsa
7、打開 ~/.ssh/id_rsa.pub文件, 復制其中所有的內容。然後把它粘貼到github的ssh key(在右上角頭像->Settings->左邊菜單SSH and GPG keys->new SSH keys)添加的表單中。
執行以下命令來測試key。
$ ssh -T [email protected]
如果你看到:
The authenticity of host ‘github.com (207.97.227.239)‘ 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”並回車。
8、當你看到以下內容時, 你就添加成功了。
Hi username! You‘ve successfully authenticated, but GitHub does not
provide shell access.
9、Git全局用戶配置
# git config --global user.name "xxx"
# git config --global user.email [email protected]
10、克隆遠程庫過程
git init 初始化倉庫
git remote add origin ([email protected]:xiaoemoxiw/HLD-Laravel-Test.git)github項目上的地址
git pull origin master
11、上傳更新文件
git add .
git commit -m ‘填寫完成了哪些模塊‘
git push origin master
12、沖突解決
git status 查看沖突狀態
git fetch 查看分支
git reset --hard origin/master 應用git上的文件,廢除本地文件
現在我們啟動時光穿梭機,準備把readme.txt回退到上一個版本,也就是“add distributed”的那個版本,怎麽做呢?
首先,Git必須知道當前版本是哪個版本,在Git中,用HEAD表示當前版本,也就是最新的提交3628164...882e1e0(註意我的提交ID和你的肯定不一樣),上一個版本就是HEAD^,上上一個版本就是HEAD^^,當然往上100個版本寫100個^比較容易數不過來,所以寫成HEAD~100。
現在,我們要把當前版本“append GPL”回退到上一個版本“add distributed”,就可以使用git reset命令:
$ git reset --hard HEAD^
HEAD is now at ea34578 add distributed
本文出自 “11822904” 博客,請務必保留此出處http://11832904.blog.51cto.com/11822904/1954085
Centos6.7或7.2系統中 github配置及基本使用