亚洲国产日韩欧美一区二区三区,精品亚洲国产成人av在线,国产99视频精品免视看7,99国产精品久久久久久久成人热,欧美日韩亚洲国产综合乱

directory search
Guides gitattributes giteveryday gitglossary gitignore gitmodules gitrevisions gittutorial gitworkflows Administration git archive git bundle git clean git filter-branch git fsck git gc git instaweb git reflog Basic Snapshotting git add git commit git diff git mv git reset git rm git status Branching and Merging git branch git checkout git log git merge git mergetool git stash git tag Debugging git bisect git blame git grep Email git am git format-patch git request-pull git send-email External Systems git fast-import git svn Getting and Creating Projects git clone git init Git git annotate git archimport git bisect-lk2009 git check-attr git check-mailmap git check-ref-format git checkout-index git cherry git citool git column git credential git credential-cache git credential-store git cvsexportcommit git cvsimport git cvsserver git diff-files git diff-tree git difftool git fast-export git fetch-pack git fmt-merge-msg git get-tar-commit-id git gui git http-backend git http-fetch git http-push git imap-send git index-pack git interpret-trailers git ls-remote git ls-tree git mailinfo git mailsplit git merge-file git merge-index git merge-one-file git merge-tree git mktag git mktree git name-rev git notes git p4 git pack-objects git pack-redundant git pack-refs git parse-remote git patch-id git prune git prune-packed git quiltimport git receive-pack git remote-ext git remote-fd git remote-testgit git repack git replace git rerere git send-pack git sh-i18n git sh-setup git shell git show-branch git show-index git stripspace git unpack-file git unpack-objects git upload-archive git upload-pack git var git verify-commit git verify-tag git whatchanged git worktree Inspection and Comparison git describe git shortlog git show Miscellaneous api credentials api index gitcli gitcore tutorial gitcredentials gitcvs migration gitdiffcore githooks gitk gitnamespaces gitremote helpers gitrepository layout gitsubmodules gittutorial 2 gitweb gitweb.conf pack format User Manual Patching git apply git cherry-pick git rebase git revert Plumbing Commands git cat-file git check-ignore git commit-tree git count-objects git diff-index git for-each-ref git hash-object git ls-files git merge-base git read-tree git rev-list git rev-parse git show-ref git symbolic-ref git update-index git update-ref git verify-pack git write-tree Server Admin git daemon git update-server-info Setup and Config git git config git help Sharing and Updating Projects git fetch git pull git push git remote git submodule
characters

命名

git-rm  - 從工作樹和索引中刪除文件

概要

git rm [-f | --force] [-n] [-r] [--cached] [--ignore-unmatch] [--quiet] [--] <file>…

描述

從索引中刪除文件,或從工作樹和索引中刪除文件。git rm不會從您的工作目錄中刪除文件。(沒有選擇只從工作樹中刪除文件,而是將其保留在索引中; /bin/rm如果您想這樣做,則使用該選項。)被刪除的文件必須與分支的提示相同,并且不會更新他們的內容可以放在索引中,盡管這個默認行為可以被-f選項覆蓋。當--cached給出時,分階段內容必須匹配分支的尖端或磁盤上的文件,從而允許從索引中刪除文件。

選項

<file>…

要刪除的文件。*.c可以給 Fileglobs(例如)刪除所有匹配的文件。如果你想讓 Git 擴展文件全局字符,你可能需要 shell 來逃避它們。一個主要的目錄名(例如dir刪除dir/file1dir/file2)可以刪除目錄中的所有文件,遞歸地刪除所有子目錄,但是這需要-r明確給出選項。

-f   --force

覆蓋最新的檢查。

-n   --dry-run

切勿刪除任何文件。相反,只需顯示它們是否存在于索引中,否則將被命令刪除。

-r

當給出主目錄名時允許遞歸刪除。

--

此選項可用于將命令行選項與文件列表分開,(當文件名可能被誤認為是命令行選項時很有用)。

--cached

使用此選項可以取消僅從索引中刪除路徑的情況。工作樹文件,無論是否修改,都將被單獨保留。

--ignore-unmatch

即使沒有匹配的文件,也可以用零狀態(tài)退出。

-q   --quiet

git rm通常rm為每個被刪除的文件輸出一行(以命令的形式)。該選項禁止輸出。

討論

給該命令的 <file> 列表可以是精確的路徑名,文件全局模式或主目錄名。該命令僅刪除 Git 已知的路徑。給出你沒有告訴 Git 的文件的名稱不會刪除該文件。

跨越目錄邊界的文件匹配匹配。因此,給定兩個目錄dd2使用git rm 'd*'和之間有區(qū)別git rm 'd/*',因為前者也會刪除所有目錄d2。

刪除已從文件系統(tǒng)中消失的文件

沒有選擇git rm只從索引中刪除從文件系統(tǒng)中消失的路徑。但是,根據(jù)使用情況,有幾種方法可以完成。

使用“git commit -a”

如果您打算您的下一次提交應記錄工作樹中所有跟蹤文件的所有修改,并記錄已從工作樹中刪除的所有文件的清除rm(而不是git rm),請使用git commit -a,因為它會自動通知并記錄所有清除。您也可以在不使用提交的情況下獲得類似的效果git add -u。

使用 “git add -A”

在接受供應商分支的新代碼丟失時,您可能需要記錄刪除路徑和添加新路徑以及修改現(xiàn)有路徑。

通常,您將首先使用以下命令從工作樹中刪除所有跟蹤的文件:

git ls-files -z | xargs -0 rm -f

然后解壓縮工作樹中的新代碼。或者,您可以rsync將更改導入工作樹。

之后,在工作樹中記錄所有刪除,添加和修改的最簡單方法是:

git add -A

參見git-add [1]。

其他方法

如果您真的想要從索引中移除工作樹中不再存在的文件(可能是因為您的工作樹不完美,以至于無法使用git commit -a),請使用以下命令:

git diff --name-only --diff-filter=D -z | xargs -0 git rm --cached

子模塊

只有使用 gitfile 的子模塊(意味著它們被克隆為 Git 1.7.8 或更高版本)將從工作樹中移除,因為它們的存儲庫位于超級項目的 .git 目錄中。如果子模塊(或其中嵌套的模塊之一)仍然使用 .git 目錄,git rm則會將子模塊 git 目錄移動到超級項目 git 目錄中以保護子模塊的歷史記錄。如果存在子模塊,gitmodules [5]文件中的 <name> 部分也將被刪除,并且該文件將被暫存(除非使用 --cached 或 -n )。

當 HEAD 與索引中記錄的相同時,子模塊被認為是最新的,沒有跟蹤的文件被修改,并且子模塊工作樹中不存在未被忽略的未跟蹤文件。忽略的文件被認為是可消耗的,并且不會阻止子模塊的工作樹被移除。

如果您只想從工作樹中刪除子模塊的本地簽出而不提交刪除,請將deinit改為使用 git-submodule [1] 。有關子模塊刪除的詳細信息,另請參閱 gitsubmodules [7] 。

例子

git rm Documentation/\*.txt

*.txt從索引中刪除Documentation目錄及其任何子目錄下的所有文件。

請注意,*在本例中星號是從 shell 引用的; 這讓 Git(而不是shell)能夠擴展目錄下的文件和子目錄的路徑名Documentation/。

git rm -f git-*.sh

因為這個例子讓 shell 擴展了星號(即你明確列出了這些文件),所以它不會被刪除subdir/git-foo.sh

Bugs

每次父項目更新移除已填充的子模塊時(例如,在移除之前和之后在提交之間切換時),舊的子模塊簽出將保留在舊位置。刪除舊目錄僅在使用 gitfile 時才是安全的,否則子模塊的歷史記錄也會被刪除。執(zhí)行遞歸子模塊更新時,此步驟將會過時。

Previous article: Next article: