2017-08-01 8 views
-1

のいずれかを引っ張っしたくない、拒否された。ここにgitの状態です:Gitのプッシュが

Macs-MacBook:crime_type_class_mlmodel macuser$ git status 
On branch master 
Your branch and 'origin/master' have diverged, 
and have 2 and 9 different commits each, respectively. 
    (use "git pull" to merge the remote branch into yours) 

Changes not staged for commit: 
    (use "git add/rm <file>..." to update what will be committed) 
    (use "git checkout -- <file>..." to discard changes in working directory) 

    deleted: 20170628_somefile.txt 
    deleted: model.R 
    deleted: somecsv.csv 
    deleted: somecsv1.csv 
    modified: rscripts/.RData 
    modified: rscripts/.Rhistory 
    modified: rscripts/preprocessing.R 
    deleted: somecsv2.csv 

Untracked files: 
    (use "git add <file>..." to include in what will be committed) 

    .DS_Store 
    .RData 
    .Rhistory 
    database snippets.sql 
    output_csvs/ 

私がコミットしようとしています私のローカルディレクトリからgithubへの2つのファイル。

のMac-のMacBook:crime_type_class_mlmodelのマックユーザー$ git pull origin master

From https://github.com/ourco/myprojectrepo.git 
* branch   master  -> FETCH_HEAD 
error: Your local changes to the following files would be overwritten by merge: 
    rscripts/.RData 
    rscripts/.Rhistory 
Please, commit your changes or stash them before you can merge. 
Aborting 

これら2つのファイル.RDataと.RHistoryにはないメッセージにより示唆されるように

git push origin master 


To https://github.com/ourco/myprojectrepo.git 
! [rejected]  master -> master (non-fast-forward) 
error: failed to push some refs to 'https://github.com/ourco/myprojectrepo.git' 
hint: Updates were rejected because the tip of your current branch is behind 
hint: its remote counterpart. Integrate the remote changes (e.g. 
hint: 'git pull ...') before pushing again. 
hint: See the 'Note about fast-forwards' in 'git push --help' for details. 

だから、私はgitのプルを試してみましたブラウザにアクセスしたときにレポに表示されます。私はgithubでそれらをしたくないし、私はそれらをローカルで上書きしたくない。これらの2つのファイルは私のローカルディレクトリにあるはずです。だから、私はそれらを上書きすることに懸念している。

model.Rファイルとpreprocessing.Rファイルの両方をgithubにコミットする方法はありますか?

+1

.Gitignoreファイルに.RDataと.Rhistoryを追加することをお勧めします。 R – shaojl7

答えて

2

これらのファイルを.gitignoreに追加すると、gitは変更を気にせず、したがって競合については不平を言いません。

また、あなたが一時的に隠しておくことができます。

git stash save

を次に、あなたのマージ/リベース/

git stash pop

を引っ張るんそして、彼らは戻っています。あなたが他の人が(代わりにインタラクティブgit add -pフラグを使用せずに、いたずらgit add -aまたはgit add .を行うことによって)レポに追加されていることを見つけている場合

また、あなたが変更とレポに.gitignoreをコミットする必要があります。残念ながら、それらのファイルは既に追跡されているので、ステップでそれを行う必要があります。ファイルを削除し、削除をコミットし、プッシュアップし、.gitignoreを更新し、&をコミットしてファイルをローカルに復元します。あなたの他の開発者にも、彼らのバックアップを取り戻さなければならないことを知ってもらいましょう。

+0

のサンプル.gitignoreファイルについては、https://github.com/github/gitignore/blob/master/R.gitignoreをご覧ください。ありがとう、非常に参考になります。だから私は自分のdi r.gitignoreに新しいファイルを作成し、無視したい両方のファイルにパスを追加するべきです。面白そうに聞こえるかもしれませんが、私はそれを見てください –

+0

私は.gitignoreに2つのファイルを追加しました。それから、git push> "あなたの現在のブランチの先端が遅れているので、更新が拒否されました"というエラーメッセージを表示しようとしました。だから私は 'git pull origin master 'を試みました。これは"ファイルをunmergedしているので、引っ張ることはできません。 "また、明示的に明確にするために、私のローカルディレクトリは最新のファイルです。私は一週間を通してこれらのスクリプトを更新しています。したがって、もし私がgit pullをしたら、現在githubにある古いバージョンで作業されていた新しいスクリプトを書くのではないでしょうか?あなたにこれまでの助けをありがとう –

+0

この新しいスクリプトをコミットしましたか? –

関連する問題