2016-11-12 6 views
1

私はgitに比較的新しく、いくつかの余分なファイルをコミットしました。また、ファイルにエラーを引き起こすものも追加しました。git commitを修正して、いくつかの余分なファイルを削除するには?

余分なファイルを削除して、編集したファイルをプッシュすることもできます。それ、どうやったら出来るの ?

P.S - 投稿者は非常に単純--force

+0

誤った素材をリモコンに押し込んだことはありますか? –

+0

はい私はそれを@TimBiegeleisen – osaid

答えて

0

そのを使用してそれを行うために私を求めています。

新しいコンテンツを編集して追加することで、ファイルシステムを希望どおりに変更できます。
コンテンツが準備できたら、ステージに追加してコミットします。

ショートバージョン:

// If you only wish to remove files from the repository 
git rm --cached <file to remove> 

// or if you only wish to remove files form disk & repo 
git rm <file to remove> 

詳細バージョン:

.. Current commited content 
.. edit any file or remove any file 

// Add the changes to the stage area. 
// Any new change here will be added to the latest commit later on 
// with the commit --amend flag 
git add <files to be changed> 

// if you wish to remove the extra files - remove them from stage 
// and commit the change 
git rm --cached <file to remove> 

// Update the latest commit and add the new changes made to the index 
git commit --ammend 

// Update remote server with the new changes 
git push -f origin <branch> 
2

ステップ1:

があなたのディスクから不要なファイルを削除します。 修正する必要があるファイルを修正してファイルを編集します。

ステップ2:

は、これらのコマンドを実行します。

git add * 
git commit -m "some message" 
git push origin master 

あなたが他のブランチで作業している場合は、ちょうどあなたの支店の名前でマスターを変更します。作業ディレクトリ作業ツリーから不要なファイルを削除するには

+1

にプッシュしましたこれは**新しいコミットを追加します**コミットしていません**コミット – CodeWizard

0

git rm <file1> <file2>... 
git add . && git commit --amend --no-edit 

--no-editオプションはできますが--amendオプションは、代わりに新しいコミットを作成するHEADで指さコミット修正コミットメッセージを変更せずにコミットを修正してください。

ディレクトリを削除するには、再帰オプション-rを使用して、削除するディレクトリ名を続けます。 --dry-runオプション(略称:-n)を使用して、削除するファイルを確認することができます。

関連する問題