A
A
Alex Mirgorodskiy2019-02-01 18:03:17
git
Alex Mirgorodskiy, 2019-02-01 18:03:17

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

2 answer(s)
M
Maxim Babichev, 2019-02-01
@REZ1DENT3

There are 2 options:
1. gitkeep
2. In the folder you need, add .gitignore with the content:

!.gitignore
*

I
Igor Deyashkin, 2019-02-14
@Lobotomist

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 question

Ask a Question

731 491 924 answers to any question