Git pull 不遵守 .gitignore



我有点困惑,做一个拉到服务器,其中我有一个.gitignore设置为忽略用户生成的文件。基本上,我正在开发和推动github,然后部署与拉,但我不断删除我的用户生成的内容。

。Gitignore看起来像这样:

audio/*/*/*.mp3
audio/*/*/*.wav
audio/*/*/*.ogg
videos/*/*/*.mp4
videos/*/*/*.mov
videos/*/*/*.mpeg
images/*/*/*.jpg
images/*/*/*.jpeg
images/*/*/*.png
images/*/*/*.gif
images/*/*/*.bmp
images/*/*/*/*.jpg
images/*/*/*/*.jpeg
images/*/*/*/*.png
images/*/*/*/*.gif
images/*/*/*/*.bmp

我对git不是特别了解,所以我知道我做错了什么。

我做错了什么?

。Gitignore用于在尝试提交文件时忽略文件。当您从存储库中提取时,它不会看到这些

我没有观察到你所说的打人行为:

环境1:

$ mkdir test
$ cd test
$ git init .
Initialized empty Git repository in /*****/test/.git/
$ cat > .gitignore <<'EOF'
> audio/*/*/*.mp3
> audio/*/*/*.wav
> audio/*/*/*.ogg
> 
> videos/*/*/*.mp4
> videos/*/*/*.mov
> videos/*/*/*.mpeg
> 
> images/*/*/*.jpg
> images/*/*/*.jpeg
> images/*/*/*.png
> images/*/*/*.gif
> images/*/*/*.bmp
> 
> images/*/*/*/*.jpg
> images/*/*/*/*.jpeg
> images/*/*/*/*.png
> images/*/*/*/*.gif
> images/*/*/*/*.bmp
> EOF
$ touch test.txt
$ mkdir -p audio/one/two/
$ touch audio/one/two/three.mp3
$ touch audio/one/two/three.txt
$ git add -A :/
$ git commit -m "Initial commit"
 3 files changed, 19 insertions(+)
 create mode 100644 .gitignore
 create mode 100644 audio/one/two/three.txt
 create mode 100644 test.txt
$ git remote add origin https://***********@bitbucket.org/***********/testrepo.git
$ git push -u origin --all
环境2:

$ git clone https://***********@bitbucket.org/***********/testrepo.git
$ cd testrepo
$ touch test2.txt 
$ git add -A :/
$ git commit -m "Commit two."
$ git push
环境1:

$ touch audio/one/two/three.wav
$ git pull
$ ls -l audio/one/two/
total 0
-rw-r--r--  1 ***********  staff  0 Sep 25 11:37 three.mp3
-rw-r--r--  1 ***********  staff  0 Sep 25 11:37 three.txt
-rw-r--r--  1 ***********  staff  0 Sep 25 11:57 three.wav

文件还在。

最新更新