Git manages multiple projects

using git to manage multiple projects encountered a problem with missing project files:
two branches established using git: one is a branch and the other is b branch.
in order to make projects independent of each other on the git branch, an empty branch of temp is established, and the new projects are all branches based on this branch. Prevent branch interference.
encountered such a problem when switching branches. In branch a, that is, project a, you now need to switch to branch b, that is, project b. After switching, it is found that the untracked file node_modules, which is ignored in branch a, is missing. I would like to ask how to deal with it so as not to lose the neglected files. First, make sure that each project is independent of each other, one branch at a time, how can you ensure that untracked files will not be lost when switching projects?

Mar.16,2021

roughly speaking, you ignored the node_modules folder on branch a, and you must have executed the npm install command on branch a, but not on branch b. Gitignore did not ignore the folder node_modules, or should you not execute the npm install command?
is a bit of a mess. I guess you are doing micro services, right? the whole large project has multiple sub-projects, and each sub-project has its own directory, and each directory has its own independent node_modules folder, so that you switch branches and directly enter the directory operation of this sub-project.
the file directory is roughly as follows:

project_all
    -- project_a
        -- node_modules
        -- src
        -- package.json
    -- project_b
        -- node_modules
        -- src
        -- package.json
    -- project_c
        -- node_modules
        -- src
        -- package.json
    .gitignore

I hope I can help you.


then you commit when switching branches.


first of all, the basic branch should be called "master".

Menu