これは何度も起こります。 私のフレームワークが私のシステム上で新しいファイルを作る時、私はgitの状態をして、 "変更された"と見えますが、それらをgitに追加/変更したくないので、 gitignoreファイル、そう? しかし、ときに私は、彼らはまだ私のgitの状態で表示されていることを実行します。だから私はことを試みた無視されたファイルは変更されたまま表示されますが、インデックスから削除すると、他のマシンで削除されます。
を::S だから私はこの問題を探し、そして出会った
git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: bootstrap/cache/services.php <<< so these 3 are already in gitignore, but still shows up :S
modified: composer.lock <<< so these 3 are already in gitignore, but still shows up :S
modified: npm-debug.log <<< so these 3 are already in gitignore, but still shows up :S
no changes added to commit (use "git add" and/or "git commit -a")
folder/projectfolder git rm -r --cached bootstrap/cache/services.php
rm 'bootstrap/cache/services.php'
folder/projectfolder git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: bootstrap/cache/services.php
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory)
modified: composer.lock
modified: npm-debug.log
folder/projectfolder git rm -r --cached composer.lock
rm 'composer.lock'
folder/projectfolder git rm -r --cached npm-debug.log
rm 'npm-debug.log'
folder/projectfolder git status
On branch master
Your branch is ahead of 'origin/master' by 1 commit.
(use "git push" to publish your local commits)
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
deleted: bootstrap/cache/services.php
deleted: composer.lock
deleted: npm-debug.log
folder/projectfolder git commit -m "clean gitindex"
[master 084a4e1] clean gitindex
Committer: ********
3 files changed, 13823 deletions(-)
delete mode 100644 bootstrap/cache/services.php
delete mode 100644 composer.lock
delete mode 100644 npm-debug.log
folder/projectfolder git status
On branch master
Your branch is ahead of 'origin/master' by 2 commits.
(use "git push" to publish your local commits)
nothing to commit, working directory clean
folder/projectfolder git push
warning: <<<message and login removed here>>>
Counting objects: 9, done.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 582 bytes | 0 bytes/s, done.
Total 6 (delta 4), reused 0 (delta 0)
To https://*****@bitbucket.org/*****/*****.git
45ty54y4y54y******y4t43at master -> master
をしかし、私の同僚がgitから自分の変更を引き出すと、gitインデックスだけでなく、3つのファイルが実際に自分のシステムから削除されます。どのようにマシン上のファイルシステムに触れることなく、gitをgitignoreのすべてのファイルを無視するようにするにはどうすればいいですか? 、と言ってP
バート
ありがとうございました。 gitに "ステータスファイル"を更新させて(おそらくそのインデックスと呼ばれていない?)、ignoreファイルを調べる方法は他にありますか?私はちょうどgitが "無視されたファイルで何もしません。ファイル名が意味するように、ちょうど無視して、変更されたことを私に伝えません。私のためにそれを無視して、私がgitステータスを行うときに私にその変更を教えてください... " –
ファイルがgitインデックスに追加されると、ファイルへの変更は' git status'に表示されます.gitignoreファイルに表示されます。これを防ぐための唯一の方法は、上記のようにファイルをインデックスから削除し、.gitignoreに追加することです。しかし、その時点で、ファイルはリポジトリに存在しません。ここには何もありません。ファイルはリポジトリに存在し、変更を追跡しているか、変更を追加して無視します。 –
ファイルを追加するHADがあるのに、変更をコミットしたくない場合は、実行しているビルドスクリプトの一部として 'git revert'を追加して、そのファイルに対する変更を常に元に戻す。 –