站長資訊網(wǎng)
        最全最豐富的資訊網(wǎng)站

        介紹Git 常用命令大全

        介紹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 強行移除修改后文件(從暫存區(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

        二、 Git 命令速查表

        1、常用的Git命令

        命令

        簡要說明

        git add

        添加至?xí)捍鎱^(qū)

        git add–interactive

        交互式添加

        git apply

        應(yīng)用補丁

        git am

        應(yīng)用郵件格式補丁

        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)建郵件格式的補丁文件。參見 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

        校驗 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

        校驗對象庫打包文件

        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

        將補丁通過 IMAP 發(fā)送

        git mailinfo

        從郵件導(dǎo)出提交說明和補丁

        git mailsplit

        將 mbox 或 Maildir 格式郵箱中郵件逐一提取為文件

        git request-pull

        創(chuàng)建包含提交間差異和執(zhí)行PULL操作地址的信息

        git send-email

        發(fā)送郵件

        7、協(xié)議相關(guān)命令

        命令

        簡要說明

        git daemon

        實現(xiàn)Git協(xié)議

        git http-backend

        實現(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)用,通過外部命令提供擴展協(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é)議擴展示例腳本

        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 cvsserver

        Git的CVS協(xié)議模擬器,可供CVS命令訪問Git版本庫

        git fast-export

        將提交導(dǎo)出為 git-fast-import 格式

        git fast-import

        其他版本庫遷移至Git的通用工具

        git svn

        Git 作為前端操作 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

        補丁過濾行號和空白字符后生成補丁唯一ID

        git quiltimport

        將Quilt補丁列表應(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 常用命令大全

        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 # 強制刪除分支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é)點
        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 是一個很強大的分布式版本控制系統(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)參與了合并的分支,對于未有合并的分支是無法刪除的。如果想強制刪除一個分支,可以使用-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)前分支的修改,否則會被強制刪干凈沒得后悔)

        $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 —-只在首次檢出倉庫時運行一次就行

        更新子模塊:$ git submodule update —-每次更新或切換分支后都需要運行一下

        刪除子模塊:(分4步走哦)

        1) $ git rm –cached [path]

        2) 編輯“.gitmodules”文件,將子模塊的相關(guān)配置節(jié)點刪除掉

        3) 編輯“ .git/config”文件,將子模塊的相關(guān)配置節(jié)點刪除掉

        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 強行移除修改后文件(從暫存區(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 常用命令圖表

        介紹Git 常用命令大全

        贊(0)
        分享到: 更多 (0)
        網(wǎng)站地圖   滬ICP備18035694號-2    滬公網(wǎng)安備31011702889846號
        主站蜘蛛池模板: 亚洲午夜精品一级在线播放放 | 色花堂国产精品第一页| 国产三级精品三级在线观看专1| 欧美精品一区二区蜜臀亚洲| 国产精品免费在线播放| 国产成人精品白浆久久69| 亚洲国产精品嫩草影院久久| 四虎影视国产精品永久在线| 无码国产精品一区二区免费16 | www国产精品| 午夜DY888国产精品影院| 国产精品热久久毛片| 国产成人精品免费视频动漫| 人人妻人人澡人人爽人人精品97| 久久久久九国产精品| 国产91精品黄网在线观看| 91精品国产91久久久久福利| 亚洲av无码精品网站| 日本精品久久久久久久久免费| 国产成人毛片亚洲精品| 久久伊人精品青青草原高清| 国产精品亚洲аv无码播放| 亚洲精品狼友在线播放| 无码精品人妻一区二区三区免费 | 国产日韩精品中文字无码 | 国产亚洲精品线观看动态图| 欧美日韩精品一区二区三区| 成人精品在线视频| 97久久精品无码一区二区天美| 乱精品一区字幕二区| 无码精品人妻一区二区三区中| 亚洲精品无码激情AV| 欧美精品黑人粗大视频| 久久精品无码一区二区三区日韩 | 国内精品免费在线观看| 91精品国产综合久久精品| 精品久久久久久亚洲精品| 日韩精品无码免费一区二区三区 | 老司机午夜精品视频资源| 久久精品人人做人人爽97| 精品亚洲国产成AV人片传媒|