質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

Q&A

解決済

2回答

1317閲覧

git mergeするとコードが全てロールバックするように消えてしまう・・。

helo

総合スコア36

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

Heroku

HerokuはHeroku社が開発と運営を行っているPaaSの名称です。RubyやNode.js、Python、そしてJVMベース(Java、Scala、Clojureなど)の複数のプログラミング言語をサポートしている。

Ruby on Rails

Ruby on Railsは、オープンソースのWebアプリケーションフレームワークです。「同じことを繰り返さない」というRailsの基本理念のもと、他のフレームワークより少ないコードで簡単に開発できるよう設計されています。

0グッド

0クリップ

投稿2020/01/18 14:56

編集2020/01/19 11:22
gitは、以下の順で実施しえちます。 $ rails test $ git add -A  warning: LF will be replaced by CRLF in app/assets/javascripts/account_activations.coffee. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/assets/stylesheets/account_activations.scss. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/controllers/account_activations_controller.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/helpers/account_activations_helper.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/mailers/user_mailer.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/views/user_mailer/account_activation.html.erb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/views/user_mailer/account_activation.text.erb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/views/user_mailer/password_reset.html.erb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in app/views/user_mailer/password_reset.text.erb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in db/migrate/20200112080817_add_activation_to_users.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in test/controllers/account_activations_controller_test.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in test/mailers/previews/user_mailer_preview.rb. The file will have its original line endings in your working directory warning: LF will be replaced by CRLF in test/mailers/user_mailer_test.rb. The file will have its original line endings in your working directory $ git commit -m "Add account activation" [account-activation 90ea9d4] Add account activation 30 files changed, 247 insertions(+), 69 deletions(-) create mode 100644 app/assets/javascripts/account_activations.coffee create mode 100644 app/assets/stylesheets/account_activations.scss create mode 100644 app/controllers/account_activations_controller.rb create mode 100644 app/helpers/account_activations_helper.rb create mode 100644 app/mailers/user_mailer.rb create mode 100644 app/views/user_mailer/account_activation.html.erb create mode 100644 app/views/user_mailer/account_activation.text.erb create mode 100644 app/views/user_mailer/password_reset.html.erb create mode 100644 app/views/user_mailer/password_reset.text.erb create mode 100644 db/migrate/20200112080817_add_activation_to_users.rb create mode 100644 test/controllers/account_activations_controller_test.rb delete mode 100644 test/integration/user_signup_test.rb create mode 100644 test/mailers/previews/user_mailer_preview.rb create mode 100644 test/mailers/user_mailer_test.rb $ git checkout master Switched to branch 'master' Your branch is up to date with 'origin/master'. $ git merge account-activation $ git merge account-activation error: cannot stat 'app/views/user_mailer': Permission denied error: cannot stat 'app/views/user_mailer': Permission denied error: cannot stat 'app/views/user_mailer': Permission denied error: cannot stat 'app/views/user_mailer': Permission denied Updating a79ce83..90ea9d4 上記エラーのapp/views/user_mailer.rbのコードです。        ↓ class UserMailer < ApplicationMailer # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.user_mailer.account_activation.subject # def account_activation(user) @user = user mail to: user.email, subject: "Account activation" end # Subject can be set in your I18n file at config/locales/en.yml # with the following lookup: # # en.user_mailer.password_reset.subject # def password_reset @greeting = "Hi" mail to: "to@example.org" end end ```### 前提・実現したいこと 現在、Railsチュートリアルの第11章を最終git mergeすると、記述したcodeが全て消え、記述前状態に戻ってしまいます。 2回やってみましたが、2回とも同じ現象になり、また、エディター(Atom)を消そうとするとsaveにするとそのまま閉じずに エクスプローラーが立ち上がりaccount_activation.text.erbファイルの保存を促してきます。 というより、保存しないとエディターが閉じませんでした。 一体、何が起こっているのか見当もつかず困惑している状況です。 詳しい方、居られましたらアドバイス頂けないでしょうか。 よろしくお願いします。 ### 発生している問題・エラーメッセージ

エラーメッセージ

### 該当のソースコード ```ここに言語名を入力 ソースコード

試したこと

ここに問題に対して試したことを記載してください。

補足情報(FW/ツールのバージョンなど)

ここにより詳細な情報を記載してください。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

winterboum

2020/01/19 03:53

実行した git のコマンドとそのレスポンスを載せてください
helo

2020/01/19 11:00

winterboum様 コメントありがとうございます。 いま、3度目のaddにトライするところです。これでもまたエラーと rollback現象がmergeの後、出るかと思いますので、そちらを載せるようにいたします。
helo

2020/01/19 11:24

winterboum様 やはり3度目も同じく失敗に終わりました。。。 gitとレスポンスを更新いたしました。如何でしょうか。
winterboum

2020/01/19 12:18

失敗とは「記述したcodeが全て消え、記述前状態に戻ってしまいます。」ですか?
helo

2020/01/19 12:54

mergeの後、そのエラーで失敗するのですが、ファイルを確認すると 11章の始める際の状況に戻ってしまっているんです。
guest

回答2

0

ベストアンサー

症状としてはhttps://teratail.com/questions/60939と同じに見えます。

別のプロセス(アプリケーション)でファイルやディレクトリを開いた状態でgitコマンドを実行していないでしょうか。

投稿2020/01/22 14:00

bsdfan

総合スコア4520

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

helo

2020/01/24 13:58

bsdfan様 回答ありがとうございます。 gitを行うときは、git bashターミナルで行いますがエディターのatomと rails serverが起動しているだけなのですが、これらが問題あるのでしょうか?
helo

2020/01/24 14:24 編集

どうしてもエラーが出てしまいまうのですが・・・。
bsdfan

2020/01/24 15:18

あくまで推測なのですが ・atomでapp/views/user_mailer/account_activation.text.erbを開いている ・masterをチェックアウト ・gitがmasterにないファイルやディレクトリを削除(しようとする) ・atomが開いているので、ファイルは削除できるが、ディレクトリは削除できない ・app/views/user_mailerが削除途中という状態で残る ・git mergeを実行 ・削除途中のapp/views/user_mailerにファイルを作ろうとする ・エラー という流れかと思われます。 プログラムを終了しただけでは解決しなければ、OS再起動して試してみてください。
helo

2020/01/25 00:33

bsdfan様 仰られるような流れで、確かにトラブルになっているのがよく分かりました。今しがた、Windowsを立ち上げてgit checkout account-activationブランチ変更したのですが、やはり以下のエラーが出てしまいます。 ここには、.coffeeのようなgem名が入ったりしているのですがこれらを 移動または削除しなさいとgitは言っているとういうことですが・・。 どうすればこの状況から脱する事が出来るのか・・・。 error: The following untracked working tree files would be overwritten by checkout: app/assets/javascripts/account_activations.coffee app/assets/stylesheets/account_activations.scss      ・      ・    test/mailers/user_mailer_test.rb Please move or remove them before you switch branches. Aborting
bsdfan

2020/01/25 04:12

いろいろ操作したため、ワーキングツリーがごちゃごちゃになってそうです。 いまのファイル一式をどこかにバックアップした上でgit cleanしてしまうのが確実かと。そのあと git checkout . git checkout master git merge account-activation でどうでしょう。
helo

2020/01/25 06:06

bsdfan様 アドバイスありがとうございます。 確かに、mergeした際によく分からない状態になっているのは間違いないと思いますので、仰られるようにやってみます。
helo

2020/01/25 06:19

bsdfan様 すいません。一つ質問なのですが、git clean のオプションはこの場合 --forceで良いのでしょうか?
helo

2020/01/25 06:47

bsdfan様 無事、解決することが出来ました。ありがとうございます。 感謝いたします。これでまた引き続き進めることが出来ます。 良い勉強にもなりました。 本当にありがとうございました。m(_)m
guest

0

git のレスポンスをみると、mergeが失敗しているため 元々のmasterのままになっているだけに見えます。
account-activation に戻せば復活しているでしょう。
問題は
error: cannot stat 'app/views/user_mailer': Permission denied
が出ていること。
まさか、とは思うのですが、、、
ls -l app/views
するとどうなりますか

投稿2020/01/19 13:13

winterboum

総合スコア23284

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

helo

2020/01/19 13:16

コンソールは以下が出ました。 $ ls -l app/views total 12 drwxr-xr-x 1 tae-t 197609 0 1月 19 13:14 account_activations/ drwxr-xr-x 1 tae-t 197609 0 1月 11 17:18 layouts/ drwxr-xr-x 1 tae-t 197609 0 1月 3 15:49 sessions/ drwxr-xr-x 1 tae-t 197609 0 12月 28 20:06 shared/ drwxr-xr-x 1 tae-t 197609 0 12月 28 18:18 static_pages/ drwxr-xr-x 1 tae-t 197609 0 1月 19 20:12 user_mailer/ drwxr-xr-x 1 tae-t 197609 0 1月 18 23:18 users/
helo

2020/01/19 13:36

winterboum様 如何でしょうか。まさか・・とは、不味い状態なのでしょうか。 それから トピックブランチに戻す方法は、git resetで良いのでしょうか?
winterboum

2020/01/19 14:06

「まさか」というのは、drwxr-xr-x になっていない、ということです。 なってますね。。。 トピックブランチに戻す方法は git checkout トピックブランチ です。 ごちゃごちゃ言われたら git checkout -f トピックブランチ
helo

2020/01/19 14:24

drwxr-xr-xというのは、このままこのチュートリアルは続けられないような 失敗とかでしょうか。 以下、やってみたのですがやはりfatal:が出てダメでした・・。 $ git checkout -f account-activation fatal: cannot create directory at 'app/views/user_mailer': Permission denied
helo

2020/01/19 14:28

今しがた、エディターを確認すると、ツリーのapp~modelesまでのファイル内容は復旧していました。views以下はダメでした。
helo

2020/01/19 14:41

以下の2つのファイルが消えていて、 app/views/user_mailer/account_activation.html.erb app/views/user_mailer/account_activation.text.erb user_mailerディレクトリ自体がツリーから消えていました。 トピックブランチが戻らないのもこの事が影響しているようです。 drwxr-xr-xとなってしまっていることが大元なのでしょうか・・・。
winterboum

2020/01/19 22:06

drwxr-xr-xというのは、正しいです。 なのに dir app/views/user_mailer がなんかおかしいのですね。 はて、、、
winterboum

2020/01/19 22:09

chmod 777 app/views/user_mailer してからもういちど checkout してみてください
helo

2020/01/20 01:04

winterboum様 ありがとうございます。 drwxr-xr-xは問題ないのですね・・。 ターミナルでchmod 777 app/views/user_maileをやったのち、 chekoutしてみたら、以下のエラーふが出ました。 如何でしょうか。何か移動もしくは削除のようなメッセージが出ております。 $ git checkout account-activation error: Your local changes to the following files would be overwritten by checkout: app/controllers/sessions_controller.rb app/controllers/users_controller.rb app/helpers/sessions_helper.rb app/mailers/application_mailer.rb app/models/user.rb Please commit your changes or stash them before you switch branches. error: The following untracked working tree files would be overwritten by checkout: app/assets/javascripts/account_activations.coffee app/assets/stylesheets/account_activations.scss app/controllers/account_activations_controller.rb app/helpers/account_activations_helper.rb app/mailers/user_mailer.rb app/views/user_mailer/account_activation.html.erb db/migrate/20200112080817_add_activation_to_users.rb test/controllers/account_activations_controller_test.rb test/mailers/previews/user_mailer_preview.rb test/mailers/user_mailer_test.rb Please move or remove them before you switch branches. Aborting
winterboum

2020/01/20 01:52

1) 「drwxr-xr-xは問題ないのですね・・」通常はそれが正解です。でも Permission deniedがでるのでおかしいので 777 にしてもらいました。drwxrwxrwx に変わってると思います。 2) いろいろ出ているのは、masterからaccount-activationへの変更が変な具合に終わっているから、かもしれません。いろいろ言われている fileを名指しで git checkout account-activation のようにしたのち、もういちど checkout してみてください master と
helo

2020/01/20 14:05

winterboum様 アドバイスありがとうございます。 drwxr-xr-xに関しては、やはりこのままでした・・。 2)「いろいろ言われている fileを名指しでgit checkout account-activation のようにしたのち、もういちど checkout してみてください」 、というのが、すいません今一つ理解できません。 これはどのようにすれば良いのでしょうか? 理解力不足で申し訳ありません。ご教示お願いします。
winterboum

2020/01/20 14:30

2020/01/20 10:04 のコメントにでているfileを全部 git checkout app/controllers/sessions_controller.rb の様にしてください そのあとで git checkout account-activation してみてください ん?!!!!! chmod 777 app/views/user_mailer しても drwxr-xr-x ですか? chmod 777 app/views/user_mailer した時のレスポンスを見たい あと、 tae-t で loginして chmod や git 操作していますよね?
bsdfan

2020/01/20 14:55

横からすいません。環境はWindowsですか?
helo

2020/01/21 11:39

winterboum様 先にに載せました、app/controllers/sessions_controller.rbからapp/models/user.rbの行までは、checkoutすると全て以下のメッセージが出ました。 Updated 1 path from the index しかし、下のファイルグループをやってみると以下のメッセージです。 $ git checkout app/assets/javascripts/account_activations.coffee error: pathspec 'app/assets/javascripts/account_activations.coffee' did not match any file(s) known to git その後、git checkout account-activationしますと、以下のエラーが・・。 error: The following untracked working tree files would be overwritten by checkout: app/assets/javascripts/account_activations.coffee app/assets/stylesheets/account_activations.scss app/controllers/account_activations_controller.rb app/helpers/account_activations_helper.rb app/mailers/user_mailer.rb app/views/user_mailer/account_activation.html.erb db/migrate/20200112080817_add_activation_to_users.rb test/controllers/account_activations_controller_test.rb test/mailers/previews/user_mailer_preview.rb test/mailers/user_mailer_test.rb Please move or remove them before you switch branches. Aborting なぜ、この状態は一体どうなっているのか私にはさっぱり解りません。 如何でしょうか・・。 それから、$ chmod 777 app/views/user_mailerを行ってもコンソールは 何も出てこないです。 tae-tでログインしてやっております。
helo

2020/01/21 11:40

bsdfan様 コメントありがとうございます。 はい、Windowsです。
helo

2020/01/25 06:51

winterboum様 いつもお世話になっております。 今回は、何とか無事に終えました。この度も、ご丁寧な対応とアドバイスを頂きましてありがとうございました。rails頑張ります。 一先ず、御礼まで。m(_)m
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問