github - After Git ignores the file, it appears in other files after switching branches.
PHP中文网
PHP中文网 2017-05-02 09:28:50
0
3
682

For example, my project has two branches

    $ git branch
      master
    * dev

There are two three folders under the dev branch that are ignored: bower_components/, node_modules/, dist/.

Now after I submitted under dev, I switched to the master branch. As a result, I can also see the master, bower_components/, node_modules/ directories and the files in them under the dist/ branch. Did I do something wrong? How to solve it?

PHP中文网
PHP中文网

认证高级PHP讲师

reply all(3)
小葫芦

If these files appear in version management, it’s because

.gitignore file is in version control

dev分支下的 .gitignore 记录了你要忽略的文件
但是在masterUnder the branch, .gitigonre has not recorded the content you want to ignore

Solution (update master’s .gitignore)

Method 1. merge dev -> master
Method 2. add ignore files in .gitignore at master branch

漂亮男人

If you modify the code in one branch and submit it, it will have no impact on other branches. In the same way, if you just ignore the file under the dev branch, it will have no impact on other branches, so what you have to do is to repeat the ignored action on other branches, or merge the changes under the dev branch to other branches. Branch to go.

伊谢尔伦

It’s not that your operation is incorrect, but that after you add it to gitignore, git doesn’t care about these files anymore, so switching does not switch branches, these files are all there

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template