Answer the question
In order to leave comments, you need to log in
How to put a folder in git ignore, but at the same time it was attached to the project?
Hello everyone, I’m sawing 2 versions of the site, an up-to-date one, and a completely new one (Another engine and a bunch of other folders), as I switch to new_branch, everything is fine, everything is in place, as soon as I return to the master, some folders from new_branch are pulled up, although they are not in master, they even there are ignore in git, such as vendor and other yii folders, can you tell me how to designate them so that they do not go into another branch when changing? This is due to the fact that folders in git ignore, they are not assigned to version control , and remain where they were, even when changing branches, the goal is to designate the folder as part of the git project, but so that it does not push to the server, any ideas?
Answer the question
In order to leave comments, you need to log in
There are 2 options:
1. gitkeep
2. In the folder you need, add .gitignore with the content:
!.gitignore
*
As far as I understand, the problem arises due to the fact that, by default, when a branch is checked out, ignored and simply untracked files are not removed from the working directory.
You wrote that you have added the files of the new project to .gitignore. This is not a dubious idea:
You can remove everything from the .gitignore of the old project that belongs to the new one and simply remove all untracked files and folders on checkout with the command git clean -fd . But this is not very convenient because
Most likely, in your case, the most adequate solution would be to have two working directories - for the current version of the project and for the new one. And in rare cases, when you happen to be switching between these versions within the same working directory, rungit clean -fd
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question