Git
是一款版本控制软件,配合GitHub
可以更好的控制代码
SSH Key
1 2 3 4
| $ ssh-keygen -t rsa -C "975062472@qq.com" $ cd ~/.ssh $ cat id_rsa.pub $ ssh -T git@github.com
|
创建仓库
1 2 3 4 5 6 7 8 9 10
| $ mkdir study_cpp $ cd study_cpp/ $ echo "# test" >> README.md $ ls README.md $ git init $ git add README.md $ git commit -m "添加 README.md 文件" $ git remote add origin git@github.com:Tony031218/study_cpp.git $ git push -u origin master
|
克隆
1
| $ git clone git@github.com:Tony031218/study_cpp
|
提取
1 2
| $ git fetch origin $ git merge origin/master
|
推送
1 2 3
| $ git add <filename> $ git commit -m "推送信息" $ git push origin master
|
远程仓库
1 2 3 4
| $ git remote add origin2 git@github.com:Tony031218/study_cpp.git $ git remote -v $ git remote rm origin2 $ git remote -v
|
分支
1 2 3 4 5
| $ git checkout -b graph //创建分支,并切换过去 $ git checkout master //回到主分支 $ git push origin graph //将分支推送到远程仓库 $ git pull //将本地仓库更新 $ git diff graph master //显示差别
|
克隆分支
1 2 3 4
| $ git clone -b <branch_name> <repo_url> $ cd <repo> $ git branch -a $ git checkout -b <branch_name> origin/<branch_name>
|