這里總結(jié)了一下自己常用的Git命令,會持續(xù)更新。
*創(chuàng)建SSH密鑰(公私鑰創(chuàng)建在C:\Users\Account\.ssh\)
$ ssh-keygen
*配置用戶名與郵箱
$ git config --global user.name "用戶名"
$ git config --global user.email "郵箱"
*在當(dāng)前目錄初始化一個Git倉庫
$ git init
*復(fù)制整個項目到本地
$ git clone [url]
*從遠(yuǎn)程獲取最新版本到本地分支,進(jìn)行比較后合并
$ git fetch origin master:tmp
$ git diff tmp
$ git merge tmp
*從遠(yuǎn)程獲取最新版本到本地分支,并直接合并
$ git pull origin master
*從本地提交文件到遠(yuǎn)程
$ git add [file1][file2]
$ git add .
$ git commit -m [message]
$ git push -u origin master
*刪除本地及遠(yuǎn)程的文件
$ git rm [file1]
$ git commit -m [message]
$ git push -u origin master
*顯示當(dāng)前Git的配置
$ git config --list
*顯示變更的文件
$ git status
*顯示變更歷史
$ git log
*顯示所有遠(yuǎn)程倉庫
$ git remote -v