Answer the question
In order to leave comments, you need to log in
GIT - how to remove files (except ignored ones) from a third-party folder?
Well, I don't know, maybe I want a lot, (git won't even bother to keep track of empty folders ..)
So, I want to clone into a test folder, but before that, clear it of the previous contents. But, since clone does not transfer the files specified via gitignore, this cleanup should not affect these files.
Is that possible?
Answer the question
In order to leave comments, you need to log in
In general, the problem here is that there are 2 types of ignored files
1 - for example, configs with access to the database
2 - any technical garbage such as caches, logs
When deploying, you need to save the first ones in the target folder and delete the second ones.
Git doesn't have a file like
.gittrash
cache/*
cd /path/to/target
git clean -d -f -x --exclude=/path/to/config.php --exclude=/path/to/onemorefile.php
git clone /repo.git .git-i- hate-you
\cp -rf .git-i-hate-you/. .
\rm -rf .git-i-hate-you
I need to remove the files known to git while keeping the ones defined by gitignore
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question