In a repository I have there are lots of unnecessary files, which I would like to remove from the repo and only keep locally. I understand that this is done by:
git rm --cached a_file
... or with -r
in case it's a folder.
Now, it's easier to remove everything and add the few files I need. If I use *
, git rightly complains when it's given files that are not in the repo, but in the same local folder.
How should I proceed?
EDIT: Using the -f
flag won't work either:
$ git rm --cached -fr *
fatal: pathspec 'somefile' did not match any files
The --ignore-unmatch
flag for git rm
does exactly what you want from what I can tell.
$ git rm --cached bla
fatal: pathspec 'bla' did not match any files
$ git rm --cached --ignore-unmatch bla
$
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.