0
2

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 1 year has passed since last update.

他のメンバーがマージした時にgit pullをして作業中のブランチに反映させる方法

Last updated at Posted at 2023-03-24

対象者

・Gitに不慣れな人
・共同開発中の人
・git pullを知っている人

この記事の背景

とある共同開発をしていた時のことです。
自分がログイン機能とログアウト機能を実装していた時のことです。
ログイン機能を実装して名前とパスワードを入力し、ログインするぞーと
思ったら以下のエラーがでました。

スクリーンショット 2023-03-23 22.36.38.png

原因はusersのtableが実装されていないことが原因でした。
users_tableは自分のタスクではなかったので、メンバーAが実装を終わるのを
待つことになりました。実装が終わり、メンバーAがマージをしました。
その時に新しく反映されたdevelopブランチから
作業中のブランチに反映することになり、git pullをすることになりました。

このように他のメンバーがマージした時に自分にも反映させることは
あるあるなので手順を書いておきます。

作業中のgit pullの手順

まずはgitの状態を確認します。
そして作業ブランチfeatureにいることを確認します。

laravelapp % git branch
*feature/~

laravelapp % git status 

次に以下の手順でコミットしていきます。

laravelapp % git add . 
laravelapp % git commit -m "コミット内容" 

developブランチに移動します。

laravelapp % git checkout develop  

そしてpullをします。

laravelapp % git pull origin develop

pullできたらgit statusで状態も確認しておきます。作業ブランチに移動します。

 laravelapp % git checkout feature/~

そしてgit mergeをします。

laravelapp % git merge develop

これで無事反映されてエラーも解決できてタスクが進みました。

stashを使う場合もある

こんな表示が出る場合もあります。

省略
Please commit your changes or stash them before you merge.
Aborting

コミットするかマージする前にstashしろ!ってエラーが出てくる場合があります。
この時は自分はプッシュをしていませんでした。
新しく自分の作業ブランチに反映させるには

git stash

を使います。

有益な記事

0
2
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
0
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?