github - git how to filter files or directories
PHP中文网
PHP中文网 2017-05-02 09:50:48
0
3
865

The git I built locally is then associated to the github repository, and the server pulls content from github.
Now I want to filter out the configuration files when submitting, because the configurations on the local and server are different
Then I wrote a .gitignore file with the configuration file directory in it. This method did not work. The local changes are pushed to github. When the server pulls from github, it still pulls the changes in the configuration file directory without filtering them out.

The second method is to directly add the configuration file directory to the local .gitinfoexclude but it still fails to be filtered. What's going on? The following are the rules written. .gitignore is added both on the server and locally. The second one is only added locally

PHP中文网
PHP中文网

认证0级讲师

reply all(3)
世界只因有你

First of all, the poster needs to make it clear that the local file will be automatically read when it is added to the temporary storage area. .gitignore文件,根据其中的设置过滤相应的文件。所以楼主应该在添加到暂存区之前,就判断.gitignore文件是否生效,而不是推送到远程了才判断。
你可以通过git status -s命令查看那些想过滤的文件是否被过滤掉,如果没有,那么很可能是因为那些文件之前已经在暂存区,.gitignoreFiles cannot filter those files that have been previously in the temporary storage area. In this case, you can use the following command:

git rm --cached files-you-want-to-ignore

At this time, you can use the git status -s command to check if it is indeed ignored, then you can perform subsequent add, commit, and push operations.

阿神

You have given a method to filter files.
Maybe these files have been added to the warehouse. If you don’t want to track the files in the warehouse, follow the following command
Ignore tracking

$ git update-index --assume-unchanged /path/to/file       

Resume tracking

$ git update-index --no-assume-unchanged /path/to/file  
我想大声告诉你

is .gitignore 规则没生效 要先git rm -r --cached

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