本地倉庫操作git status:檢視檔案狀態
git status -v :使輸出更加簡潔
git add hello.txt:將未跟蹤的檔案新增到暫存區
git reset hello.txt:將暫存區的檔案取消暫存
git commit -m "add hello.txt":將暫存區的檔案提交到本地倉庫並新增相關的日誌資訊
git rm hello.txt:刪除檔案,此處刪除的只是工作區的檔案,刪除後還需要提交到本地倉庫(git commit -m "delete hello.txt")
git log:檢視日誌記錄
遠端倉庫操作git remote:檢視遠端倉庫
git remote -v:檢視遠端倉庫資訊簡潔輸出
git remote add [remote-name] [remote-url]:新增乙個新的遠端git倉庫,同時指定乙個可以引用的簡寫
git clone [url]:從遠端倉庫轉殖
git remote rm [remote-name]:移除無效的遠端倉庫;此命令只是從本地移除遠端倉庫的記錄,並不會影響到遠端倉庫
git fetch [url]:是從遠端倉庫獲取最新版本到本地倉庫,不會自動merge
git merge [branch-name]:合併分支
git pull [url]:是從遠端倉庫獲取最新版本並merge到本地倉庫
注意:如果當前本地倉庫不是從遠端倉庫轉殖,而是本地建立的倉庫,並且倉庫中存在檔案,此時再從遠端倉庫拉 取檔案的時候會報錯(fatal: refusing to merge unrelated histories ),解決此問題可以在git pull命令後加入參 數--allow-unrelated-histories
git push [remote-name] [branch-name]:推送到遠端倉庫
git分支git branch :檢視本地倉庫分支-r:檢視遠端倉庫分支-a:檢視本地和遠端倉庫分支
git branch [branchname]:建立分支
git checkout [branchname]:切換分支
git push [倉庫名] [branchname]:將分支推送至遠端倉庫分支
git branch -d [branchname]:刪除分支,刪除的是本地的分支
如果要刪除的分支中進行了一些開發動作,此時執行上面的刪除命令並不會刪除分支,如果堅持要刪除此分支,可 以將命令中的-d引數改為-dgit branch -d [branchname]:刪除分支
git push origin -d branchname:刪除遠端倉庫中的分支
git標籤git tag:檢視所有標籤
git tag [tag-name]:建立標籤
git push origin [標籤名]:推送標籤至遠端倉庫
git checkout -b branch
:新建乙個分支,指向某個tag
git tag -d [tag]:刪除本地tag
git push origin :refs/tags/[tag]:刪除遠端tag
常用命令 Git 常用命令大全
安裝教程可參照 廖雪峰老師的安裝教程。git config 在git中,使用git config 命令來配置 git 的配置檔案,git配置級別主要有3類 1 倉庫級別 local 本地 git 倉庫級別配置檔案,作用於當前倉庫。優先順序最高 2 使用者級別 global,全域性配置檔案,作用於所有...
git 常用命令
檢視是否存在檔案需要上傳 git status git add git commit m 建立遠端倉庫 git remote add origin 116.255.146.153 ruby cd work daily project.git 更新git fetch 116.255.146.153 r...
git常用命令
詳細 1,git log p 命令來顯示每一次提交與其父節點提交內容之間快照的差異。2,為了檢視載入 staged 而並未提交 not committed 的內容差異,可以使用 git diff stage 命令 在git 1.6之前的版本中,使用 cached 適應情形 在執行git commit...