由于公司項目一直是用svn管理項目,一直沒接觸到git,前不久自學(xué)了一段時間,研究了一下命令行指令,在這分享給大家,也相當(dāng)于給自己做個學(xué)習(xí)筆記。如果有錯誤也希望多多指正。
(三個區(qū)域為工作區(qū)=>暫存區(qū)=>版本區(qū))最后到github上
git clone url ? ? ? ? //url為在git上的地址
git config --global user.name "zhang" ?//給自己的項目起個名字 名字叫zhang
git config --global user.email "8*******9@qq.com" ?//郵箱地址
git status //查看項目狀態(tài)
git add index.html ? ?//把index.html添加到暫存區(qū)
git commit index.html ? ?//把文件添加到版本區(qū)
git commit -m ? //把所有文件上傳到版本區(qū)
git commit -a -m "index.html" ?//把文件index.html從工作區(qū)上傳到版本區(qū)
git log //查看提交的版本
git diff ?//查看暫存區(qū)和工作區(qū)的區(qū)別
git diff --cached ? //查看版本區(qū)與暫存區(qū)的區(qū)別
git diff master ? //查看工作區(qū)與版本區(qū)的區(qū)別
git reset HEAD comm.js ?//把comm.js從暫存區(qū)撤銷到工作區(qū)
git checkout --comm.js ? ? //把comm.js從版本區(qū)撤銷到暫存區(qū)
git rm index.html ? ?//把index.html從工作區(qū)刪除
git reset --hard HEAD` ? ?//恢復(fù)成上個歷史版本
git pull ? //從git hub上直接拉取合并
git push orgin/master ?//提交到github上
工作中用了git現(xiàn)在對git命令進行補充
一.日常提交代碼
1.git status ? ?//先查看狀態(tài)
2.git add -A ?//如果本地有修改則提交所有修改的文件 ?
3.git commit -m "注釋"?
4.git push orgin master ?//提交到遠程倉庫的主分支
二.創(chuàng)建獨立分支
1.進入到本地準(zhǔn)備當(dāng)獨立分支代碼的根目錄 git init
2.git add .
3.git commit -m "新建分支"?
4.git branch vueyudu
5.git checkout ?vueyudu
6.git remote add origin url //url為master分支的地址
7.git push origin vueyudu