How to put a folder in the git ignore, but she was tied to the project?

0 like 0 dislike
11 views
Hi all, Sawing 2 versions of the website, relevant, and brand new(the Other engine and a bunch of other folders), as I pass on new_branch all the rules all over the place as soon as we return to the master, pulled some folders from new_branch to master although they are not, they are even in git ignore, such as vendor and other yii-shnye folder, do not tell me how to identify them, so that they did not climb in another branch with the change?This happens due to the fact that folder to git ignore, they are not placed in version control, and stay down where he lay, even if you change branches, the goal is to designate a folder as part of the project git, but that she did not pusies to the server, any ideas?
asked by | 11 views

2 Answers

0 like 0 dislike
As I understand it, the problem arises from the fact that by default, when checking out code branch and just ignore untracked (untracked) files are not deleted from the working directory.

Preamble

You wrote that the new project files you have added in .gitignore. It's not a bad idea:
  • It turns out that you have in the code of the old project is ignoring the new project files. In the branch the old code should not be that applies to the new.
  • If you ignore a file new project, and then to remove them you need to either explicitly specify what files you want to remove or delete all ignored files. Among them may be such that you need, for example, the code of third-party delitek, if you have one, or your local configs, etc.


You can remove from .gitignore old project that relates to a new and just delete all untracked files and folders when checking out code using the command git clean-fd. But it is not very convenient because
  • When switching between branches will be created and deleted many files, and this extra load on the FS time
  • To enter these commands by hand most likely lazy (although you can write the alias for their automation)

The decision

Most likely in your case the most appropriate solution is to have two working directories for the current version of the project and for the new. And on the rare occasions when you get so that you make the switch between these two versions within the same working directory to run git clean-fd
answered by
0 like 0 dislike
There are 2 options:
1. gitkeep
2. In the folder add .gitignore with the contents:
!.gitignore *
answered by

Related questions

0 like 0 dislike
2 answers
0 like 0 dislike
2 answers
0 like 0 dislike
3 answers
0 like 0 dislike
3 answers
asked Mar 28 by kirchevsky
0 like 0 dislike
2 answers
110,581 questions
257,150 answers
0 comments
476 users