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

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

新規登録して質問してみよう
ただいま回答率
85.46%
git-flow

git-flowとは、gitのブランチモデルを使う時の補助ツールです。gitを使う際のブランチ作成などで、一定のルールをまとめたものを指します。

Q&A

解決済

1回答

692閲覧

Git Actions CI/CD Deployできない

ken123789

総合スコア1

git-flow

git-flowとは、gitのブランチモデルを使う時の補助ツールです。gitを使う際のブランチ作成などで、一定のルールをまとめたものを指します。

0グッド

0クリップ

投稿2021/09/13 05:10

前提・実現したいこと

ここに質問の内容を詳しく書いてください。
(例)ローカル開発してGitHubからEC2でアプリケーションを作成しました。
Gemfileの変更、マイグレーションファイルの変更機能を実装中に以下のエラーメッセージが発生しました。

発生している問題・エラーメッセージ

エラーメッセージ Your local changes to the following files would be overwritten by merge: 32 Gemfile.lock

該当のソースコード

echo "$PRIVATE_KEY" > private_key && chmod 600 private_key 3 ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOST_NAME} 'cd SDGs-PF && 4 git pull origin main && 5 ~/.rbenv/shims/bundle install && 6 ~/.rbenv/shims/bundle exec rails assets:precompile RAILS_ENV=production && 7 ~/.rbenv/shims/bundle exec rails db:migrate RAILS_ENV=production && 8 if [[ -e tmp/pids/puma.pid ]];then sudo kill $(cat tmp/pids/puma.pid); echo kill puma process;fi && 9 ~/.rbenv/shims/rails s -e production' 10 shell: /usr/bin/bash -e {0} 11 env: 12 PRIVATE_KEY: *** 13 USER_NAME: *** 14 HOST_NAME: *** 15 Warning: Permanently added '***' (ECDSA) to the list of known hosts. 16 From github.com:kinoshitaken123/SDGs-PF 17 * branch main -> FETCH_HEAD 18 81aaf68..d84ef38 main -> origin/main 19 hint: Pulling without specifying how to reconcile divergent branches is 20 hint: discouraged. You can squelch this message by running one of the following 21 hint: commands sometime before your next pull: 22 hint: 23 hint: git config pull.rebase false # merge (the default strategy) 24 hint: git config pull.rebase true # rebase 25 hint: git config pull.ff only # fast-forward only 26 hint: 27 hint: You can replace "git config" with "git config --global" to set a default 28 hint: preference for all repositories. You can also pass --rebase, --no-rebase, 29 hint: or --ff-only on the command line to override the configured default per 30 hint: invocation. 31 error: Your local changes to the following files would be overwritten by merge: 32 Gemfile.lock 33 Please commit your changes or stash them before you merge. 34 Aborting 35 Error: Process completed with exit code 128.

試したこと

Gemfileの変更
1. ローカルで変更をコミットし、リモートリポジトリへpushする
2. SSHでEC2へ接続する
3. アプリケーションへ移動する
4. git pullコマンドを実行する
5. 以下コマンドを実行する

$ bundle install --path vendor/bundle --without test development

マイグレーションファイルの変更
1. ローカルで変更をコミットし、リモートリポジトリへpushする
2. SSHでEC2へ接続する
3. アプリケーションへ移動する
4. git pullコマンドを実行する
5. マイグレーションを行う

$ bundle exec rails db:migrate RAILS_ENV=production

gitからhintがあったので以下を実施しました

hint: git config pull.rebase false # merge (the default strategy) hint: git config pull.rebase true # rebase hint: git config pull.ff only # fast-forward only

ご対応よろしくお願いします。

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

ruby '2.6.3'
gem 'rails', '> 5.2.5'
gem 'puma', '
> 3.11'

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

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

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

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

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

guest

回答1

0

ベストアンサー

git pull origin main コマンドでエラーが起こっています。

pull しようとしている環境で既存の Gemfile.lock に変更がありマージできないようです。

git status で何が変更されているのか確認してください。

git checkout コマンドでバージョン管理中の最新状態まで戻すことが出来ます。

text

1git checkout -- Gemfile.lock

投稿2021/09/13 06:15

mather

総合スコア6753

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

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

ken123789

2021/09/13 06:34

ご回答いただき有難うございます。 Gemfile.lock に変更がありマージできないエラーの切り分けはできました。 ただ、git status では nothing to commit, working tree cleanと表示され、 git checkout コマンドでバージョン管理中の最新状態まで戻すことできません。 現在も同じようにデプロイができない状態となっています。 その辺含めて再度、調査してみます。
mather

2021/09/13 06:35

> pull しようとしている環境で ここが大事です。ローカルで git status していませんか?
ken123789

2021/09/13 12:56

ローカルで git status 実施していました。 本番環境で実施行ったところ無事解決できました
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.46%

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

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

質問する

関連した質問