符號(hào)說(shuō)明:"[ ]"表示必填內(nèi)容,填充后刪去左右的"[]"穷绵,"{}"表示選填內(nèi)容带斑,填充后刪去左右"{}".
新建工程之后常用的命令
Command line instructions
Git global setup
git config --global user.name "balabala"
git config --global user.email "zorro.luo@outlook.com"
Create a new repository
git clone https://www.zorroluo/JustDoIt.git
cd JustDoIt
touch README.md
git add README.md
git commit -m "add README"
git push -u origin master
Existing folder
cd existing_folder
git init
git remote add origin https://www.zorroluo/JustDoIt.git
git add .
git commit -m "add something"
git push -u origin master
Existing Git repository
cd existing_repo
git remote add origin https://www.zorroluo/JustDoIt.git
git push -u origin --all
git push -u origin --tags
運(yùn)用Mac Command Line命令來(lái)定位到目標(biāo)文件夾: cd [local directory address]
當(dāng)前目錄初始化為Git倉(cāng)庫(kù): git init
添加工作區(qū)的變化到暫存區(qū):git add [file1] {file2}
添加所有變化到暫存區(qū):git add .
添加暫存區(qū)的變化到倉(cāng)庫(kù)區(qū):git commit -m "remark something"
查看工作區(qū)的狀態(tài):git status
查看工作區(qū)和倉(cāng)庫(kù)區(qū)不同之處: git diff {HEAD --} [file]
查看提交記錄:git log {--pretty=}
查看全部歷史確認(rèn)提交記錄:git reflog
退回工作區(qū)到上一個(gè)提交的版本:git reset --hard HEAD^
退回工作區(qū)到某一個(gè)提交的歷史版本:git reset --hard [commit id]
撤銷(xiāo)工作區(qū)還未添加到暫存區(qū)的修改:git checkout -- [file]
撤銷(xiāo)工作區(qū)已經(jīng)添加到暫存區(qū)的修改:git reset HEAD [file]
刪除文件:git rm [file]
席噩,然后提交:git commit -m "something"
遠(yuǎn)程倉(cāng)庫(kù)模捂,創(chuàng)建SSH Key的命令:
ssh-keygen -t rsa -C "email address"
倉(cāng)庫(kù)區(qū)和遠(yuǎn)程倉(cāng)庫(kù)建立連接:git remote add origin [remote directory address]
倉(cāng)庫(kù)區(qū)的內(nèi)容推送到遠(yuǎn)程倉(cāng)庫(kù):git push {-u} origin master
克隆遠(yuǎn)程倉(cāng)庫(kù)到本地目錄:git clone [remote directory address]
創(chuàng)建分支:git branch [branch name]
切換分支:git checkout [branch name]
創(chuàng)建分支并切換到該分支:git checkout -b [branch name]
查看分支:git branch
合并其它分支到當(dāng)前分支:git merge [other branch name]
刪除分支:git branch -d [other branch name]
圖形化參數(shù)查看分支合并的情況:git log --graph {--pretty=oneline --abbrev-commit}
分支合并是非Fast forward模式寂嘉,這樣合并后可以看到分支的歷史:git merge --no-ff -m "say something" dev
臨時(shí)任務(wù)時(shí),對(duì)變動(dòng)的暫存功能:git stash
創(chuàng)建標(biāo)簽:git tag [tag name] {command id}
查看所有標(biāo)簽:git tag
查看標(biāo)簽信息:git show [tag name]
創(chuàng)建標(biāo)簽時(shí)添加文字說(shuō)明:git tag -a [tag name] -m "say something" {command id}
刪除標(biāo)簽:git tag -d [tag name]
推送標(biāo)簽到遠(yuǎn)程倉(cāng)庫(kù):git push origin [tag name]
一次推送所有標(biāo)簽:git push origin --tags
刪除遠(yuǎn)程標(biāo)簽:第一:刪除本地枫绅,第二:git push origin :refs/tags/[tag name]
相關(guān)實(shí)用鏈接
1.簡(jiǎn)書(shū)的Markdown使用教程
2.廖雪峰官網(wǎng)比較全面詳細(xì)的Git教程
3.阮一峰的常用Git命令清單
4.Git 圖解、常用命令和廖雪峰教程筆記總結(jié)
5.圖解Git