Git忽略

作用

?在Git的項目中編寫.gitignore文件可以忽略Git中不想提交的文件。

    以配置文件setting.properties模擬
    新建文件 echo nul->setting.properties
    此時git status
        On branch new_branch //在new_branch分支上
        Untracked files: //為追蹤的文件
        (use "git add <file>..." to include in what will be committed)//可以使用add命令去添加需被提交的文件

            setting.properties //為追蹤的文件

        nothing added to commit but untracked files present (use "git add" to track)//沒有修改去提交但是存在未追蹤的文件
    
    新建文件 echo nul->.gitignore
    此時git status
    On branch new_branch //在new_branch上
    Untracked files: //未追蹤的文件
    (use "git add <file>..." to include in what will be committed)//可以使用add命令去添加需要被提交的文件

        .gitignore
        setting.properties

    nothing added to commit but untracked files present (use "git add" to track) //沒有修改將要提交(暫存區(qū)沒有修改信息),但是存在未追蹤的文件
    
    我們需要setting.properties文件不被git版本控制系統(tǒng)監(jiān)控-----忽略
    在.gitignore中添加setting.properties文件
    
    vi .gitignore文件 
    按i進(jìn)入插入模式,輸入setting.properties,按ESC進(jìn)入命令模式,輸入:wq 回車
    此時git status
    On branch new_branch //在new_branch分支上
    Untracked files://未追蹤的文件
    (use "git add <file>..." to include in what will be committed)

        .gitignore //需添加的文件

    nothing added to commit but untracked files present (use "git add" to track)
    //此時setting.properties已經(jīng)在需追蹤的文件中 取消(就是忽略了)
    

忽略規(guī)則

?空行或者#號開頭的行,是無效行/注釋行
?以斜杠“/”開頭表示目錄
?以星號“*”通配多個字符
?以問號“?”通配單個字符
?以嘆號“!”表示取反

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容