git 代碼託管html
去Git官網上下載安裝便可git
$cd ~/.ssh //若是說沒有這個目錄,就直接看第三步
$ssh-keygen -t rsa -C "email"
("email" git帳號)
以後直接回車,不用填寫東西。以後會讓你輸入密碼。而後就生成一個目錄.ssh ,裏面有兩個文件:id_rsa , id_rsa.pubgithub
用記事本打開id_rsa.pub文件,複製內容,在github.com的網站上到ssh密鑰管理頁面,添加新公鑰,隨便取個名字,內容粘貼剛纔複製的內容。shell
而後把id_rsa.pub裏的內容複製進去就能夠了。
app
指令:ssh
$ git config --global user.name 「your_username」
$ git config --global user.email 「your_registered_github_Email」
ssh -T git@github.com
The authenticity of host 'github.com (192.30.252.129)' can't be established.ide
RSA key fingerprint is 16:27:xx:xx:xx:xx:xx:4d:eb:df:a6:48.測試
Are you sure you want to continue connecting (yes/no)? yes #確認你是否繼續聯繫,輸入yes網站
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of known hosts.code
Enter passphrase for key '/c/Users/xxxx_000/.ssh/id_rsa': #生成ssh kye是密碼爲空則無此項,若設置有密碼則有此項且,輸入生成ssh key時設置的密碼便可。
Hi xxx! You've successfully authenticated, but GitHub does not provide shell access. #出現此句話,說明設置成功。
git clone 地址
//先放進本地倉庫 git add . git commit -m '本次提交備註' git status //查看倉庫狀態
git push
git pull //將當前分支綁定的遠程分支的最新的修改拉取到本地,通常在咱們push以前都應該pull拉取一下查看是否有衝突
git reflog //回溯歷史版本 git reset --hard //回溯到指定狀態,只要提供目標時間點的哈希值
https://jingyan.baidu.com/article/48206aea68e69f216ad6b33f.html
git branch //顯示分支一覽表,同時確認當前所在的分支 git checkout -b aaa //建立名爲aaa的分支,而且切換到aaa分支 (git branch aaa //建立名爲aaa的分支 git checkout aaa // 切換到aaa分支)能和git branch -b aaa 獲得一樣的效果
git checkout <主分支> //先切換到合併的分支 git merge <被合併的分支> -m '填寫一個合併的信息' //再將指定分支合併到當前分支 git push
查看當前已合併的和未合併過的分支,可見其餘分支中沒有合併的內容
git branch --merged git branch --no-merged
(參考)http://www.javashuo.com/article/p-aljjaxus-v.html
github上已經有master分支 和dev分支
在本地
git checkout -b dev // 新建並切換到本地dev分支 git pull origin dev //本地分支與遠程分支相關聯
在本地新建分支並推送到遠程
git checkout -b test git push origin test //這樣遠程倉庫中也就建立了一個test分支
error: Your local changes to the following files would be overwritten by merge: src/test/resources/application_context.xml Please, commit your changes or stash them before you can merge. Aborting
爲解決此問題,作以下操做
git stash
隱藏本地修改
git pull
下載最新代碼
git stash pop
從Git棧中讀取最近一次保存的內容,恢復本身的本地修改
提示有無衝突
如有衝突,則解決衝突
若無,則直接提交
git add .
git commit -m "comments"
fatal: The current branch v2.0.6 has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin v2.0.6
複製執行便可
git push --set-upstream origin v2.0.6