1. 程式人生 > >Git常用操作命令大全

Git常用操作命令大全

Git常用操作命令大全:

1) 遠端倉庫相關命令

檢出倉庫:$ git clone git://github.com/jquery/jquery.git

檢視遠端倉庫:$ git remote -v

新增遠端倉庫:$ git remote add [name] [url]

刪除遠端倉庫:$ git remote rm [name]

修改遠端倉庫:$ git remote set-url --push [name] [newUrl]

拉取遠端倉庫:$ git pull [remoteName] [localBranchName]

推送遠端倉庫:$ git push [remoteName] [localBranchName]

Git 常用命令

git branch 檢視本地所有分支
git status 檢視當前狀態
git commit 提交
git branch -a 檢視所有的分支
git branch -r 檢視本地所有分支
git commit -am "init" 提交併且加註釋
git remote add origin [email protected]:ndshow
git push origin master 將檔案給推到伺服器上
git remote show origin 顯示遠端庫origin裡的資源
git push origin master:develop
git push origin master:hb-dev 將本地庫與伺服器上的庫進行關聯
git checkout --track origin/dev 切換到遠端dev分支
git branch -D master develop 刪除本地庫develop
git checkout -b dev 建立一個新的本地分支dev
git merge origin/dev 將分支dev與當前分支進行合併
git checkout dev 切換到本地dev分支
git remote show 檢視遠端庫
git add .
git rm 檔名(包括路徑) 從git中刪除指定檔案
git clone git://github.com/schacon/grit.git 從伺服器上將程式碼給拉下來
git config --list 看所有使用者
git ls-files 看已經被提交的
git rm [file name] 刪除一個檔案
git commit -a 提交當前repos的所有的改變
git add [file name] 新增一個檔案到git index
git commit -v 當你用-v引數的時候可以看commit的差異
git commit -m "This is the message describing the commit" 新增commit資訊
git commit -a -a是代表add,把所有的change加到git index裡然後再commit
git commit -a -v 一般提交命令
git log 看你commit的日誌
git diff 檢視尚未暫存的更新
git rm a.a 移除檔案(從暫存區和工作區中刪除)
git rm --cached a.a 移除檔案(只從暫存區中刪除)
git commit -m "remove" 移除檔案(從Git中刪除)
git rm -f a.a 強行移除修改後檔案(從暫存區和工作區中刪除)
git diff --cached 或 $ git diff --staged 檢視尚未提交的更新
git stash push 將檔案給push到一個臨時空間中
git stash pop 將檔案從臨時空間pop下來

git remote add origin [email protected]:username/Hello-World.git
git push origin master 將本地專案給提交到伺服器中

git pull 本地與伺服器端同步

git push (遠端倉庫名) (分支名) 將本地分支推送到伺服器上去。
git push origin serverfix:awesomebranch

git fetch 相當於是從遠端獲取最新版本到本地,不會自動merge
git commit -a -m "log_message" (-a是提交所有改動,-m是加入log資訊) 本地修改同步至伺服器端 :
git branch branch_0.1 master 從主分支master建立branch_0.1分支
git branch -m branch_0.1 branch_1.0 將branch_0.1重新命名為branch_1.0
git checkout branch_1.0/master 切換到branch_1.0/master分支
du -hs


mkdir WebApp
cd WebApp
git init
touch README
git add README
git commit -m 'first commit'
git remote add origin [email protected]:daixu/WebApp.git
git push -u origin master