git文件管理心得分享
untraked file 未跟蹤的文件,通常為新建立的文件
traked file 通常為建立索引之后的文件
ignored 被忽略的文件,這類型的文件通常在一個文件列表中。維護(hù)這個列表的文件在版本庫根目錄名字為 .gitignore
初始化版本庫,保證剛創(chuàng)建狀態(tài)
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ ls hello huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ ls -a ./ ../ .git/ hello huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ rm -rf .git/ hello huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo $ git init Initialized empty Git repository in C:/Users/huawei/Desktop/git-repo/.git/
創(chuàng)建文件查看文件類型,發(fā)現(xiàn)為untraked file未被跟蹤的文件
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ echo "hello world" > hello huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ git status On branch master No commits yet Untracked files: (use "git add <file>..." to include in what will be committed) hello nothing added to commit but untracked files present (use "git add" to track)
被跟蹤的文件通常為建立索引之后的文件,可以通過git ls-files -s查看。至于被忽略的文件可以看下面的演示,將文件名寫入到.gitignore文件即可
huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ git status On branch master nothing to commit, working tree clean huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ echo "a" > a huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ git status On branch master Untracked files: (use "git add <file>..." to include in what will be committed) a nothing added to commit but untracked files present (use "git add" to track) huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ echo a >> .gitignore huawei@DESKTOP-JTC012C MINGW64 ~/Desktop/git-repo (master) $ git status On branch master 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)
.gitignore文件語法
#開頭的行用于注釋
空行會被注釋
目錄名末尾用反斜線(/)標(biāo)記
包含shell通配符,如*。例 debug/32bit/*.o
起始地感嘆號用于取反模式
版權(quán)聲明:本站文章來源標(biāo)注為YINGSOO的內(nèi)容版權(quán)均為本站所有,歡迎引用、轉(zhuǎn)載,請保持原文完整并注明來源及原文鏈接。禁止復(fù)制或仿造本網(wǎng)站,禁止在非maisonbaluchon.cn所屬的服務(wù)器上建立鏡像,否則將依法追究法律責(zé)任。本站部分內(nèi)容來源于網(wǎng)友推薦、互聯(lián)網(wǎng)收集整理而來,僅供學(xué)習(xí)參考,不代表本站立場,如有內(nèi)容涉嫌侵權(quán),請聯(lián)系alex-e#qq.com處理。
關(guān)注官方微信