溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點(diǎn)擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

Git-命令

發(fā)布時間:2020-07-01 08:46:40 來源:網(wǎng)絡(luò) 閱讀:1179 作者:_追隨我心 欄目:軟件技術(shù)

寫在前面的話:

GitHub是個git倉庫(相當(dāng)于Git服務(wù)器),安裝在遠(yuǎn)程服務(wù)器端。

git是一個客戶端工具,安裝在用戶的電腦上,用戶通過git命令從GitHub上pull和push數(shù)據(jù)。

 

Git工作原理圖

Git-命令

Git-命令


 資料地址:

  1. http://www.ruanyifeng.com/blog/2015/12/git-cheat-sheet.html

  2. http://www.cnblogs.com/springbarley/archive/2012/11/03/2752984.html

 

Windows上需要安裝git客戶端(git是命令行工具|GitHub是代碼倉庫)

 

remote:遠(yuǎn)程

repository :倉庫

checkout:檢出

 

 

mkdir  makefile   新建目錄

cd  makefile

git init 初始化本地倉庫

touch readme.txt  新建文件

git add readme.txt 添加文件到暫存區(qū)

git commit -m "first comomit"  提交文件到本地倉庫,first comomit為備注

 

在本地倉庫添加一個遠(yuǎn)程倉庫

git remote add origin git@git.yongche.org:yinyongjie/git-test.git

 

git push 或者 git push -u origin master 提交文件到遠(yuǎn)程倉庫

 

從遠(yuǎn)程倉庫刪除文件:

git rm --f "文件名"

git commit -m "delete file"     備注:delete file為備注,可以隨便寫 

git push

 

git強(qiáng)制覆蓋本地:

git fetch --all

git reset --hard origin/master

git pull 或者 git push -u origin master

 

git branch 查看所有本地分支

git branch -r 查看所有遠(yuǎn)程分支

git branch -a  查看所有本地和遠(yuǎn)程分支

 

git branch -d master1  刪除本地的分支名master1

 

git branch baidu 創(chuàng)建baidu分支

git checkout baidu 切換到baidu分支

git checkout – 切換到上一個分支

git checkout –b yidao 創(chuàng)建yidao分支并立即切換到y(tǒng)idao分支

 

git push origin yidao 把本地分支yidao push到遠(yuǎn)程分支

git push origin yidao:master 提交本地yidao分支到master分支(合并分支)

 

git merge master_team 把主分支合并到當(dāng)前分支

 

git clone git@git.yongche.org:mayi/BackendAutoTesting.git   克隆代碼到本地

 

git checkout . (取消所有本地的修改)

git log (查看提交歷史) 按q鍵退出

git status

 


向AI問一下細(xì)節(jié)

免責(zé)聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點(diǎn)不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進(jìn)行舉報,并提供相關(guān)證據(jù),一經(jīng)查實(shí),將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI