简体   繁体   English

GIT:推送后不需要的文件

[英]GIT: Unwanted files after a push

I'm using openshift, I have a remote git repository that look like this :我正在使用 openshift,我有一个远程 git 存储库,如下所示:

 .gitignore (contains "data/") 
 /source
 - test.php 
 /data
 - 1.png
 - 2.jpg

I checkout this repository on my computer.我在我的电脑上签出这个存储库。 Then I change test.php .然后我更改test.php In same time, I deleted on the remote repository the files : 1.png & 2.jpg and I add the file smile.jpg .同时,我删除了远程存储库中的文件: 1.png & 2.jpg并添加了文件smile.jpg

remote:偏僻的:

 .gitignore (contains "data/") 
 /source
 - test.php 
 /data
 - smile.jpg

local当地的

 .gitignore (contains "data/") 
 /source
 - test.php (changed)
 /data
 - 1.png
 - 2.jpg

Then when I : git add / git commit / git push the test.php modification from my computer.然后当我: git add / git commit / git push test.php从我的电脑修改。 My smile.png is replaced by the older files ( 1.png & 2.jpg ).我的smile.png被旧文件 ( 1.png & 2.jpg ) 取代。

What did I do wrong ?我做错了什么 ? I would like to keep my smile.jpg file.我想保留我的smile.jpg文件。

PS: my remote repository is my production website and data contains all uploaded file. PS:我的远程存储库是我的生产网站, data包含所有上传的文件。 On each push, all my uploaded files are deleted :(每次推送时,我上传的所有文件都会被删除:(


git status before git commit git status之前git commit

$ git status
warning: LF will be replaced by CRLF in test.php.
The file will have its original line endings in your working directory.
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

        modified:   test.php

如果在文件已添加到 git 后将data/*文件夹添加到.gitignore ,则必须

$ git rm data/1.png ; git rm data/2.png

If you are using Openshift, you have to use the openshift ~/app-root/data folder.如果您使用的是 Openshift,则必须使用 openshift ~/app-root/data文件夹。 The following question should help you to solve your problem How to keep file sync'd in OpenShift?以下问题应该可以帮助您解决问题如何在 OpenShift 中保持文件同步?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM