GIT:推送后不需要的文件

GIT:推送后不需要的文件,git,openshift,Git,Openshift,我使用的是openshift,我有一个远程git存储库,如下所示: .gitignore (contains "data/") /source - test.php /data - 1.png - 2.jpg 我在计算机上签出此存储库。然后我更改test.php。同时,我删除了远程存储库中的文件:1.png和2.jpg,并添加了文件smile.jpg 远程: .gitignore (contains "data/") /source - test.php /data

我使用的是openshift,我有一个远程git存储库,如下所示:

 .gitignore (contains "data/") 
 /source
 - test.php 
 /data
 - 1.png
 - 2.jpg
我在计算机上签出此存储库。然后我更改
test.php
。同时,我删除了远程存储库中的文件:
1.png
2.jpg
,并添加了文件
smile.jpg

远程:

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

然后当我:
git add
/
git commit
/
git push
从我的计算机上修改
test.php
时。 My
smile.png
被旧文件(
1.png
&
2.jpg
)替换

我做错了什么?我想保留我的
smile.jpg
文件

PS:我的远程存储库是我的生产网站,
数据
包含所有上传的文件。每次推送时,我上传的所有文件都会被删除:(


git提交之前的git状态

$ 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状态
警告:test.php中的LF将替换为CRLF。
该文件将在您的工作目录中具有其原始行结尾。
论分行行长
要提交的更改:
(使用“git重置磁头…”取消分级)
修改:test.php

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

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

如果您使用的是Openshift,则必须使用Openshift
~/app root/data
文件夹。 下面的问题应该能帮助你解决问题

在提交之前,您能否共享
git status
的输出?@eush77是的,我提出了这个问题。另外,当我“浏览主文件”时,我看到这两个文件(1和2)所以…很明显,您只提交
test.php
。似乎您在
/source
目录中。您可以尝试
cd
/source
中退出,或者运行
git add..
@eush77我使用的是git gui,而
/source
文件夹中退出,事实上,我的问题是,我不明白为什么
1.png
2.jpg
是在我对
test.php
进行修改后“重新创建”的。另外,
/data
应该被忽略(就像在.gitignore中一样)——我对git真的是个新手:(您可以尝试&&Ok,我改为:
git rm data-r
。但是现在,当在
test.php
上推送更改时,远程回购上的
data
文件夹被删除^^"这是正确的,如果你没有被跟踪的
smile.jpg
;你可以在本地机器上执行此操作。
smile.jpg
不是本地创建的。我直接在远程文件夹上创建的。更清楚地说,我不明白为什么git会删除我的远程
数据
文件夹,因为它应该被忽略,不应该被跟踪当我提交/推送时,d不再出现。
$ git rm data/1.png ; git rm data/2.png