您好,登錄后才能下訂單哦!
小編給大家分享一下git常用命令有哪些,相信大部分人都還不怎么了解,因此分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后大有收獲,下面讓我們一起去了解一下吧!
一、 Git 常用命令速查
git branch 查看本地所有分支
git status 查看當(dāng)前狀態(tài)
git commit 提交
git branch -a 查看所有的分支
git branch -r 查看遠(yuǎn)程所有分支
git commit -am "init" 提交并且加注釋
git remote add origin git@192.168.1.119:ndshow
git push origin master 將文件給推到服務(wù)器上
git remote show origin 顯示遠(yuǎn)程庫origin里的資源
git push origin master:develop
git push origin master:hb-dev 將本地庫與服務(wù)器上的庫進(jìn)行關(guān)聯(lián)
git checkout --track origin/dev 切換到遠(yuǎn)程dev分支
git branch -D master develop 刪除本地庫develop
git checkout -b dev 建立一個新的本地分支dev
git merge origin/dev 將分支dev與當(dāng)前分支進(jìn)行合并
git checkout dev 切換到本地dev分支
git remote show 查看遠(yuǎn)程庫
git add .
git rm 文件名(包括路徑) 從git中刪除指定文件
git clone git://github.com/schacon/grit.git 從服務(wù)器上將代碼給拉下來
git config --list 看所有用戶
git ls-files 看已經(jīng)被提交的
git rm [file name] 刪除一個文件
git commit -a 提交當(dāng)前repos的所有的改變
git add [file name] 添加一個文件到git index
git commit -v 當(dāng)你用-v參數(shù)的時候可以看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 移除文件(從暫存區(qū)和工作區(qū)中刪除)
git rm --cached a.a 移除文件(只從暫存區(qū)中刪除)
git commit -m "remove" 移除文件(從Git中刪除)
git rm -f a.a 強(qiáng)行移除修改后文件(從暫存區(qū)和工作區(qū)中刪除)
git diff --cached 或 $ git diff --staged 查看尚未提交的更新
git stash push 將文件給push到一個臨時空間中
git stash pop 將文件從臨時空間pop下來
---------------------------------------------------------
git remote add origin git@github.com:username/Hello-World.git
git push origin master 將本地項目給提交到服務(wù)器中
-----------------------------------------------------------
git pull 本地與服務(wù)器端同步
-----------------------------------------------------------------
git push (遠(yuǎn)程倉庫名) (分支名) 將本地分支推送到服務(wù)器上去。
git push origin serverfix:awesomebranch
------------------------------------------------------------------
git fetch 相當(dāng)于是從遠(yuǎn)程獲取最新版本到本地,不會自動merge
git commit -a -m "log_message" (-a是提交所有改動,-m是加入log信息) 本地修改同步至服務(wù)器端 :
git branch branch_0.1 master 從主分支master創(chuàng)建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
git branch 刪除遠(yuǎn)程branch
git push origin :branch_remote_name
git branch -r -d branch_remote_name
-----------------------------------------------------------
初始化版本庫,并提交到遠(yuǎn)程服務(wù)器端
mkdir WebApp
cd WebApp
git init 本地初始化
touch README
git add README 添加文件
git commit -m 'first commit'
git remote add origin git@github.com:daixu/WebApp.git
增加一個遠(yuǎn)程服務(wù)器端
上面的命令會增加URL地址為'git@github.com:daixu/WebApp.git',名稱為origin的遠(yuǎn)程服務(wù)器庫,以后提交代碼的時候只需要使用 origin別名即可
二、 Git 命令速查表
1、常用的Git命令
命令簡要說明
git add添加至?xí)捍鎱^(qū)
git add–interactive交互式添加
git apply應(yīng)用補(bǔ)丁
git am應(yīng)用郵件格式補(bǔ)丁
git annotate同義詞,等同于 git blame
git archive文件歸檔打包
git bisect二分查找
git blame文件逐行追溯
git branch分支管理
git cat-file版本庫對象研究工具
git checkout檢出到工作區(qū)、切換或創(chuàng)建分支
git cherry-pick提交揀選
git citool圖形化提交,相當(dāng)于 git gui 命令
git clean清除工作區(qū)未跟蹤文件
git clone克隆版本庫
git commit提交
git config查詢和修改配置
git describe通過里程碑直觀地顯示提交ID
git diff差異比較
git difftool調(diào)用圖形化差異比較工具
git fetch獲取遠(yuǎn)程版本庫的提交
git format-patch創(chuàng)建郵件格式的補(bǔ)丁文件。參見 git am 命令
git grep文件內(nèi)容搜索定位工具
git gui基于Tcl/Tk的圖形化工具,側(cè)重提交等操作
git help幫助
git init版本庫初始化
git init-db*同義詞,等同于 git init
git log顯示提交日志
git merge分支合并
git mergetool圖形化沖突解決
git mv重命名
git pull拉回遠(yuǎn)程版本庫的提交
git push推送至遠(yuǎn)程版本庫
git rebase分支變基
git rebase–interactive交互式分支變基
git reflog分支等引用變更記錄管理
git remote遠(yuǎn)程版本庫管理
git repo-config*同義詞,等同于 git config
git reset重置改變分支“游標(biāo)”指向
git rev-parse將各種引用表示法轉(zhuǎn)換為哈希值等
git revert反轉(zhuǎn)提交
git rm刪除文件
git show顯示各種類型的對象
git stage*同義詞,等同于 git add
git stash保存和恢復(fù)進(jìn)度
git status顯示工作區(qū)文件狀態(tài)
git tag里程碑管理
2、對象庫操作相關(guān)命令
命令簡要說明
git commit-tree從樹對象創(chuàng)建提交
git hash-object從標(biāo)準(zhǔn)輸入或文件計算哈希值或創(chuàng)建對象
git ls-files顯示工作區(qū)和暫存區(qū)文件
git ls-tree顯示樹對象包含的文件
git mktag讀取標(biāo)準(zhǔn)輸入創(chuàng)建一個里程碑對象
git mktree讀取標(biāo)準(zhǔn)輸入創(chuàng)建一個樹對象
git read-tree讀取樹對象到暫存區(qū)
git update-index工作區(qū)內(nèi)容注冊到暫存區(qū)及暫存區(qū)管理
git unpack-file創(chuàng)建臨時文件包含指定 blob 的內(nèi)容
git write-tree從暫存區(qū)創(chuàng)建一個樹對象
3、引用操作相關(guān)命令
命令簡要說明
git check-ref-format檢查引用名稱是否符合規(guī)范
git for-each-ref引用迭代器,用于shell編程
git ls-remote顯示遠(yuǎn)程版本庫的引用
git name-rev將提交ID顯示為友好名稱
git peek-remote*過時命令,請使用 git ls-remote
git rev-list顯示版本范圍
git show-branch顯示分支列表及拓?fù)潢P(guān)系
git show-ref顯示本地引用
git symbolic-ref顯示或者設(shè)置符號引用
git update-ref更新引用的指向
git verify-tag校驗(yàn) GPG 簽名的Tag
4、版本庫管理相關(guān)命令
命令簡要說明
git count-objects顯示松散對象的數(shù)量和磁盤占用
git filter-branch版本庫重構(gòu)
git fsck對象庫完整性檢查
git fsck-objects*同義詞,等同于 git fsck
git gc版本庫存儲優(yōu)化
git index-pack從打包文件創(chuàng)建對應(yīng)的索引文件
git lost-found*過時,請使用 git fsck –lost-found 命令
git pack-objects從標(biāo)準(zhǔn)輸入讀入對象ID,打包到文件
git pack-redundant查找多余的 pack 文件
git pack-refs將引用打包到 .git/packed-refs 文件中
git prune從對象庫刪除過期對象
git prune-packed將已經(jīng)打包的松散對象刪除
git relink為本地版本庫中相同的對象建立硬連接
git repack將版本庫未打包的松散對象打包
git show-index讀取包的索引文件,顯示打包文件中的內(nèi)容
git unpack-objects從打包文件釋放文件
git verify-pack校驗(yàn)對象庫打包文件
5、數(shù)據(jù)傳輸相關(guān)命令
命令簡要說明
git fetch-pack執(zhí)行 git fetch 或 git pull 命令時在本地執(zhí)行此命令,用于從其他版本庫獲取缺失的對象
git receive-pack執(zhí)行 git push 命令時在遠(yuǎn)程執(zhí)行的命令,用于接受推送的數(shù)據(jù)
git send-pack執(zhí)行 git push 命令時在本地執(zhí)行的命令,用于向其他版本庫推送數(shù)據(jù)
git upload-archive執(zhí)行 git archive –remote 命令基于遠(yuǎn)程版本庫創(chuàng)建歸檔時,遠(yuǎn)程版本庫執(zhí)行此命令傳送歸檔
git upload-pack執(zhí)行 git fetch 或 git pull 命令時在遠(yuǎn)程執(zhí)行此命令,將對象打包、上傳
6、郵件相關(guān)命令
命令簡要說明
git imap-send將補(bǔ)丁通過 IMAP 發(fā)送
git mailinfo從郵件導(dǎo)出提交說明和補(bǔ)丁
git mailsplit將 mbox 或 Maildir 格式郵箱中郵件逐一提取為文件
git request-pull創(chuàng)建包含提交間差異和執(zhí)行PULL操作地址的信息
git send-email發(fā)送郵件
7、協(xié)議相關(guān)命令
命令簡要說明
git daemon實(shí)現(xiàn)Git協(xié)議
git http-backend實(shí)現(xiàn)HTTP協(xié)議的CGI程序,支持智能HTTP協(xié)議
git instaweb即時啟動瀏覽器通過 gitweb 瀏覽當(dāng)前版本庫
git shell受限制的shell,提供僅執(zhí)行Git命令的SSH訪問
git update-server-info更新啞協(xié)議需要的輔助文件
git http-fetch通過HTTP協(xié)議獲取版本庫
git http-push通過HTTP/DAV協(xié)議推送
git remote-ext由Git命令調(diào)用,通過外部命令提供擴(kuò)展協(xié)議支持
git remote-fd由Git命令調(diào)用,使用文件描述符作為協(xié)議接口
git remote-ftp由Git命令調(diào)用,提供對FTP協(xié)議的支持
git remote-ftps由Git命令調(diào)用,提供對FTPS協(xié)議的支持
git remote-http由Git命令調(diào)用,提供對HTTP協(xié)議的支持
git remote-https由Git命令調(diào)用,提供對HTTPS協(xié)議的支持
git remote-testgit協(xié)議擴(kuò)展示例腳本
8、版本庫轉(zhuǎn)換和交互相關(guān)命令
命令簡要說明
git archimport導(dǎo)入Arch版本庫到Git
git bundle提交打包和解包,以便在不同版本庫間傳遞
git cvsexportcommit將Git的一個提交作為一個CVS檢出
git cvsimport導(dǎo)入CVS版本庫到Git?;蛘呤褂?cvs2git
git cvsserverGit的CVS協(xié)議模擬器,可供CVS命令訪問Git版本庫
git fast-export將提交導(dǎo)出為 git-fast-import 格式
git fast-import其他版本庫遷移至Git的通用工具
git svnGit 作為前端操作 Subversion
9、合并相關(guān)的輔助命令
命令簡要說明
git merge-base供其他腳本調(diào)用,找到兩個或多個提交最近的共同祖先
git merge-file針對文件的兩個不同版本執(zhí)行三向文件合并
git merge-index對index中的沖突文件調(diào)用指定的沖突解決工具
git merge-octopus合并兩個以上分支。參見 git merge 的octopus合并策略
git merge-one-file由 git merge-index 調(diào)用的標(biāo)準(zhǔn)輔助程序
git merge-ours合并使用本地版本,拋棄他人版本。參見 git merge 的ours合并策略
git merge-recursive針對兩個分支的三向合并。參見 git merge 的recursive合并策略
git merge-resolve針對兩個分支的三向合并。參見 git merge 的resolve合并策略
git merge-subtree子樹合并。參見 git merge 的 subtree 合并策略
git merge-tree顯式三向合并結(jié)果,不改變暫存區(qū)
git fmt-merge-msg供執(zhí)行合并操作的腳本調(diào)用,用于創(chuàng)建一個合并提交說明
git rerere重用所記錄的沖突解決方案
10、 雜項
命令簡要說明
git bisect–helper由 git bisect 命令調(diào)用,確認(rèn)二分查找進(jìn)度
git check-attr顯示某個文件是否設(shè)置了某個屬性
git checkout-index從暫存區(qū)拷貝文件至工作區(qū)
git cherry查找沒有合并到上游的提交
git diff-files比較暫存區(qū)和工作區(qū),相當(dāng)于 git diff –raw
git diff-index比較暫存區(qū)和版本庫,相當(dāng)于 git diff –cached –raw
git diff-tree比較兩個樹對象,相當(dāng)于 git diff –raw A B
git difftool–helper由 git difftool 命令調(diào)用,默認(rèn)要使用的差異比較工具
git get-tar-commit-id從 git archive 創(chuàng)建的 tar 包中提取提交ID
git gui–askpass命令 git gui 的獲取用戶口令輸入界面
git notes提交評論管理
git patch-id補(bǔ)丁過濾行號和空白字符后生成補(bǔ)丁唯一ID
git quiltimport將Quilt補(bǔ)丁列表應(yīng)用到當(dāng)前分支
git replace提交替換
git shortlog對 git log 的匯總輸出,適合于產(chǎn)品發(fā)布說明
git stripspace刪除空行,供其他腳本調(diào)用
git submodule子模組管理
git tar-tree過時命令,請使用 git archive
git var顯示 Git 環(huán)境變量
git web–browse啟動瀏覽器以查看目錄或文件
git whatchanged顯示提交歷史及每次提交的改動
git-mergetool–lib包含于其他腳本中,提供合并/差異比較工具的選擇和執(zhí)行
git-parse-remote包含于其他腳本中,提供操作遠(yuǎn)程版本庫的函數(shù)
git-sh-setup包含于其他腳本中,提供 shell 編程的函數(shù)庫
Git命令參考手冊(文本版)
git init # 初始化本地git倉庫(創(chuàng)建新倉庫)
git config --global user.name "xxx" # 配置用戶名
git config --global user.email "xxx@xxx.com" # 配置郵件
git config --global color.ui true # git status等命令自動著色
git config --global color.status auto
git config --global color.diff auto
git config --global color.branch auto
git config --global color.interactive auto
git clone git+ssh://git@192.168.53.168/VT.git # clone遠(yuǎn)程倉庫
git status # 查看當(dāng)前版本狀態(tài)(是否修改)
git add xyz # 添加xyz文件至index
git add . # 增加當(dāng)前子目錄下所有更改過的文件至index
git commit -m 'xxx' # 提交
git commit --amend -m 'xxx' # 合并上一次提交(用于反復(fù)修改)
git commit -am 'xxx' # 將add和commit合為一步
git rm xxx # 刪除index中的文件
git rm -r * # 遞歸刪除
git log # 顯示提交日志
git log -1 # 顯示1行日志 -n為n行
git log -5
git log --stat # 顯示提交日志及相關(guān)變動文件
git log -p -m
git show dfb02e6e4f2f7b573337763e5c0013802e392818 # 顯示某個提交的詳細(xì)內(nèi)容
git show dfb02 # 可只用commitid的前幾位
git show HEAD # 顯示HEAD提交日志
git show HEAD^ # 顯示HEAD的父(上一個版本)的提交日志 ^^為上兩個版本 ^5為上5個版本
git tag # 顯示已存在的tag
git tag -a v2.0 -m 'xxx' # 增加v2.0的tag
git show v2.0 # 顯示v2.0的日志及詳細(xì)內(nèi)容
git log v2.0 # 顯示v2.0的日志
git diff # 顯示所有未添加至index的變更
git diff --cached # 顯示所有已添加index但還未commit的變更
git diff HEAD^ # 比較與上一個版本的差異
git diff HEAD -- ./lib # 比較與HEAD版本lib目錄的差異
git diff origin/master..master # 比較遠(yuǎn)程分支master上有本地分支master上沒有的
git diff origin/master..master --stat # 只顯示差異的文件,不顯示具體內(nèi)容
git remote add origin git+ssh://git@192.168.53.168/VT.git # 增加遠(yuǎn)程定義(用于push/pull/fetch)
git branch # 顯示本地分支
git branch --contains 50089 # 顯示包含提交50089的分支
git branch -a # 顯示所有分支
git branch -r # 顯示所有原創(chuàng)分支
git branch --merged # 顯示所有已合并到當(dāng)前分支的分支
git branch --no-merged # 顯示所有未合并到當(dāng)前分支的分支
git branch -m master master_copy # 本地分支改名
git checkout -b master_copy # 從當(dāng)前分支創(chuàng)建新分支master_copy并檢出
git checkout -b master master_copy # 上面的完整版
git checkout features/performance # 檢出已存在的features/performance分支
git checkout --track hotfixes/BJVEP933 # 檢出遠(yuǎn)程分支hotfixes/BJVEP933并創(chuàng)建本地跟蹤分支
git checkout v2.0 # 檢出版本v2.0
git checkout -b devel origin/develop # 從遠(yuǎn)程分支develop創(chuàng)建新本地分支devel并檢出
git checkout -- README # 檢出head版本的README文件(可用于修改錯誤回退)
git merge origin/master # 合并遠(yuǎn)程master分支至當(dāng)前分支
git cherry-pick ff44785404a8e # 合并提交ff44785404a8e的修改
git push origin master # 將當(dāng)前分支push到遠(yuǎn)程master分支
git push origin :hotfixes/BJVEP933 # 刪除遠(yuǎn)程倉庫的hotfixes/BJVEP933分支
git push --tags # 把所有tag推送到遠(yuǎn)程倉庫
git fetch # 獲取所有遠(yuǎn)程分支(不更新本地分支,另需merge)
git fetch --prune # 獲取所有原創(chuàng)分支并清除服務(wù)器上已刪掉的分支
git pull origin master # 獲取遠(yuǎn)程分支master并merge到當(dāng)前分支
git mv README README2 # 重命名文件README為README2
git reset --hard HEAD # 將當(dāng)前版本重置為HEAD(通常用于merge失敗回退)
git rebase
git branch -d hotfixes/BJVEP933 # 刪除分支hotfixes/BJVEP933(本分支修改已合并到其他分支)
git branch -D hotfixes/BJVEP933 # 強(qiáng)制刪除分支hotfixes/BJVEP933
git ls-files # 列出git index包含的文件
git show-branch # 圖示當(dāng)前分支歷史
git show-branch --all # 圖示所有分支歷史
git whatchanged # 顯示提交歷史對應(yīng)的文件修改
git revert dfb02e6e4f2f7b573337763e5c0013802e392818 # 撤銷提交dfb02e6e4f2f7b573337763e5c0013802e392818
git ls-tree HEAD # 內(nèi)部命令:顯示某個git對象
git rev-parse v2.0 # 內(nèi)部命令:顯示某個ref對于的SHA1 HASH
git reflog # 顯示所有提交,包括孤立節(jié)點(diǎn)
git show HEAD@{5}
git show master@{yesterday} # 顯示master分支昨天的狀態(tài)
git log --pretty=format:'%h %s' --graph # 圖示提交日志
git show HEAD~3
git show -s --pretty=raw 2be7fcb476
git stash # 暫存當(dāng)前修改,將所有至為HEAD狀態(tài)
git stash list # 查看所有暫存
git stash show -p stash@{0} # 參考第一次暫存
git stash apply stash@{0} # 應(yīng)用第一次暫存
git grep "delete from" # 文件中搜索文本“delete from”
git grep -e '#define' --and -e SORT_DIRENT
git gc
git fsck
Git是一個很強(qiáng)大的分布式版本控制系統(tǒng)。它不但適用于管理大型開源軟件的源代碼,管理私人的文檔和源代碼也有很多優(yōu)勢。
Git常用操作命令:
1) 遠(yuǎn)程倉庫相關(guān)命令
檢出倉庫:$ git clone git://github.com/jquery/jquery.git
查看遠(yuǎn)程倉庫:$ git remote -v
添加遠(yuǎn)程倉庫:$ git remote add [name] [url]
刪除遠(yuǎn)程倉庫:$ git remote rm [name]
修改遠(yuǎn)程倉庫:$ git remote set-url --push [name] [newUrl]
拉取遠(yuǎn)程倉庫:$ git pull [remoteName] [localBranchName]
推送遠(yuǎn)程倉庫:$ git push [remoteName] [localBranchName]
*如果想把本地的某個分支test提交到遠(yuǎn)程倉庫,并作為遠(yuǎn)程倉庫的master分支,或者作為另外一個名叫test的分支,如下:
$git push origin test:master // 提交本地test分支作為遠(yuǎn)程的master分支
$git push origin test:test // 提交本地test分支作為遠(yuǎn)程的test分支
2)分支(branch)操作相關(guān)命令
查看本地分支:$ git branch
查看遠(yuǎn)程分支:$ git branch -r
創(chuàng)建本地分支:$ git branch [name] ----注意新分支創(chuàng)建后不會自動切換為當(dāng)前分支
切換分支:$ git checkout [name]
創(chuàng)建新分支并立即切換到新分支:$ git checkout -b [name]
刪除分支:$ git branch -d [name] ---- -d選項只能刪除已經(jīng)參與了合并的分支,對于未有合并的分支是無法刪除的。如果想強(qiáng)制刪除一個分支,可以使用-D選項
合并分支:$ git merge [name] ----將名稱為[name]的分支與當(dāng)前分支合并
創(chuàng)建遠(yuǎn)程分支(本地分支push到遠(yuǎn)程):$ git push origin [name]
刪除遠(yuǎn)程分支:$ git push origin :heads/[name] 或 $ gitpush origin :[name]
*創(chuàng)建空的分支:(執(zhí)行命令之前記得先提交你當(dāng)前分支的修改,否則會被強(qiáng)制刪干凈沒得后悔)
$git symbolic-ref HEAD refs/heads/[name]
$rm .git/index
$git clean -fdx
3)版本(tag)操作相關(guān)命令
查看版本:$ git tag
創(chuàng)建版本:$ git tag [name]
刪除版本:$ git tag -d [name]
查看遠(yuǎn)程版本:$ git tag -r
創(chuàng)建遠(yuǎn)程版本(本地版本push到遠(yuǎn)程):$ git push origin [name]
刪除遠(yuǎn)程版本:$ git push origin :refs/tags/[name]
合并遠(yuǎn)程倉庫的tag到本地:$ git pull origin --tags
上傳本地tag到遠(yuǎn)程倉庫:$ git push origin --tags
創(chuàng)建帶注釋的tag:$ git tag -a [name] -m 'yourMessage'
4) 子模塊(submodule)相關(guān)操作命令
添加子模塊:$ git submodule add [url] [path]
如:$git submodule add git://github.com/soberh/ui-libs.git src/main/webapp/ui-libs
初始化子模塊:$ git submodule init ----只在首次檢出倉庫時運(yùn)行一次就行
更新子模塊:$ git submodule update ----每次更新或切換分支后都需要運(yùn)行一下
刪除子模塊:(分4步走哦)
1) $ git rm --cached [path]
2) 編輯“.gitmodules”文件,將子模塊的相關(guān)配置節(jié)點(diǎn)刪除掉
3) 編輯“ .git/config”文件,將子模塊的相關(guān)配置節(jié)點(diǎn)刪除掉
4) 手動刪除子模塊殘留的目錄
5)忽略一些文件、文件夾不提交
在倉庫根目錄下創(chuàng)建名稱為“.gitignore”的文件,寫入不需要的文件夾名或文件,每個元素占一行即可,如
target
bin
*.db
=====================
Git 常用命令
git branch 查看本地所有分支
git status 查看當(dāng)前狀態(tài)
git commit 提交
git branch -a 查看所有的分支
git branch -r 查看本地所有分支
git commit -am "init" 提交并且加注釋
git remote add origin git@192.168.1.119:ndshow
git push origin master 將文件給推到服務(wù)器上
git remote show origin 顯示遠(yuǎn)程庫origin里的資源
git push origin master:develop
git push origin master:hb-dev 將本地庫與服務(wù)器上的庫進(jìn)行關(guān)聯(lián)
git checkout --track origin/dev 切換到遠(yuǎn)程dev分支
git branch -D master develop 刪除本地庫develop
git checkout -b dev 建立一個新的本地分支dev
git merge origin/dev 將分支dev與當(dāng)前分支進(jìn)行合并
git checkout dev 切換到本地dev分支
git remote show 查看遠(yuǎn)程庫
git add .
git rm 文件名(包括路徑) 從git中刪除指定文件
git clone git://github.com/schacon/grit.git 從服務(wù)器上將代碼給拉下來
git config --list 看所有用戶
git ls-files 看已經(jīng)被提交的
git rm [file name] 刪除一個文件
git commit -a 提交當(dāng)前repos的所有的改變
git add [file name] 添加一個文件到git index
git commit -v 當(dāng)你用-v參數(shù)的時候可以看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 移除文件(從暫存區(qū)和工作區(qū)中刪除)
git rm --cached a.a 移除文件(只從暫存區(qū)中刪除)
git commit -m "remove" 移除文件(從Git中刪除)
git rm -f a.a 強(qiáng)行移除修改后文件(從暫存區(qū)和工作區(qū)中刪除)
git diff --cached 或 $ git diff --staged 查看尚未提交的更新
git stash push 將文件給push到一個臨時空間中
git stash pop 將文件從臨時空間pop下來
---------------------------------------------------------
git remote add origin git@github.com:username/Hello-World.git
git push origin master 將本地項目給提交到服務(wù)器中
-----------------------------------------------------------
git pull 本地與服務(wù)器端同步
-----------------------------------------------------------------
git push (遠(yuǎn)程倉庫名) (分支名) 將本地分支推送到服務(wù)器上去。
git push origin serverfix:awesomebranch
------------------------------------------------------------------
git fetch 相當(dāng)于是從遠(yuǎn)程獲取最新版本到本地,不會自動merge
git commit -a -m "log_message" (-a是提交所有改動,-m是加入log信息) 本地修改同步至服務(wù)器端 :
git branch branch_0.1 master 從主分支master創(chuàng)建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 git@github.com:daixu/WebApp.git
git push -u origin master
以上是“git常用命令有哪些”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學(xué)習(xí)更多知識,歡迎關(guān)注億速云行業(yè)資訊頻道!
免責(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)容。