- 添加項(xiàng)目的依賴模塊
git submodule update --init
- 克隆倉(cāng)庫(kù)的master分支
git clone <url>
2.克隆倉(cāng)庫(kù)的指定分支
git clone -b <branch> <url>
3.添加文件信息到索引庫(kù),文件處于stage狀態(tài)
git add <file|.> - 索引內(nèi)容提交到本地倉(cāng)庫(kù)
git commit <-m ‘<message>’> - ********先add已經(jīng)存在并修改的文件麻敌,新增和刪除不會(huì)被add驯妄,然后提交到本地倉(cāng)庫(kù)
git commit -am ‘messge'
6.將內(nèi)容推送到遠(yuǎn)程倉(cāng)庫(kù)
git push origin <branch> - 提交本地test分支作為遠(yuǎn)程的test分支
**git push origin test:test ** - 刪除遠(yuǎn)程分支
git push origin :<branch> - 將內(nèi)容推送到遠(yuǎn)程倉(cāng)庫(kù)葡缰,并關(guān)聯(lián)遠(yuǎn)程分支,下次推送可以直接省略分支信息
git push --set-upstream origin master
10.從遠(yuǎn)程倉(cāng)庫(kù)拉取內(nèi)容
git pull origin <branch> - 創(chuàng)建分支
git branch <name> - 刪除本地分支
git branch -D <name> - 切換分支
git checkout <branch> - 新建并切換分支
git checkout -b <branch> - 還原還未被add的文件
git checkout <file|.>
16 . 合并分支
git merge [options] <branch>
17.查看最近n次的提交信息
git log -n - 查看指定文件或目錄的提交信息
git log <file/dir>
- 查看指定分支或Tag的提交信息
git log <branch|tag> - 查詢commit之前的記錄漆腌,包含commit的提交信息
git log <commit> - 查詢commit1與commit2之間的記錄摘完,包括commit1和commit2的提交信息
git log <commit1> <commit2> - 查詢commit1與commit2之間的記錄移袍,不包括commit1但包括commit2的提交信息
git log <commit1>..<commit2> - 還原已經(jīng)add還未commit的文件
git reset HEAD <file> - 將已經(jīng)commit的內(nèi)容還原到stage狀態(tài)
git reset --soft HEAD^ - 將已經(jīng)commit的內(nèi)容還原到unstage狀態(tài),也就是還未執(zhí)行add的狀態(tài)
git reset [****--****mixed****] HEAD^ - 將已經(jīng)commit的內(nèi)容還原到當(dāng)前分支最后一次push的狀態(tài)书劝,也就是所有修改的文件全部被還原进倍,此動(dòng)作非常危險(xiǎn)
git reset --****hard HEAD^ - 將從遠(yuǎn)程獲取最新的版本到本地的test分支上 不合并。git pull 是獲取到最新版本并合并购对;
git fetch origin master