1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

【Git で困った話】シリーズ

Last updated at Posted at 2020-03-15

##Git 操作でクッソ困ったことをメモしていきます。
どうやって解決したらえーねん!という事ばかりが頻繁に起こるのでメモ。

フロー間違ってるかもだけど。

まずやったこと。

$ git status

で状態確認する。

On branch feature/useredit
# 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:    .env.example
#	modified:   app/Http/Controllers/CustomerController.php
#	modified:   config/database.php

はいはい、で

$ git commit -m "hogehoge"

で今回修正対象のファイルはControllerなので

git add app/Http/Controllers/CustomerController.php

で、Push

$ git push origin feature/useredit

###でたぜエラー!!!

 ! [rejected]        feature/useredit -> feature/useredit (fetch first)
error: failed to push some refs to 'https://github.com/oboTeamDeve/deve_obo.git'
hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first merge 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 pull') before pushing again.

とあるので、おそらくPushする前にPullしてちょ。だと思う。

で、

git pushがrejectされたときの対応方法
を参考に

$ git pull origin feature/useredit

実行。

すると、

Merge branch 'feature/useredit' of https://github.com/oboTeamDeve/deve_obo into feature/useredit

# Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

なんかcommmitメッセージ入れろや、と出てきましたが、空でも良さそうなのでそのまま:q

で、なんか色々mergeされていざアクセスしたらEroor!表示だけど、Mergeしたことで余計なコードが入っただけだから修正して無事解決。

で、git push origin feature/usereditで解決。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?