2015-09-25 84 views
0

我有點困惑,做一個拉到服務器,我有一個.gitignore設置爲忽略用戶生成的文件。基本上我正在開發並推送到github,然後部署與拉,但我不斷刪除我的用戶生成的內容。Git拉不遵守.gitignore

的.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的知識非常豐富,所以我知道我做錯了什麼。

這是什麼我做錯了?

回答

3

.gitignore是用於在您嘗試提交文件時忽略文件。當你從存儲庫中取出時,它並沒有考慮到這一點。

+0

有沒有適當的方法來拉下新的代碼庫而不影響用戶生成的內容? –

+0

考慮在git中沒有UGC? – thekbb

+0

Aaaaaarrrrrrrrrrgggghhhhhh。 –

0

我不遵守你說的重挫行爲:

環境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 

的文件仍然存在。

+0

這是因爲它在推送時被跳過了嗎? –