GithubFlow,issue
githubで対象のリモートリポジトリに行ってisuueタブを開いて
new issueからissueを作成。
#はissue番号(画像の#1)
であり、ブランチやコミットメッセージで紐づけることができる。
issueに対応するブランチを切る
$ git checkout -b 'refactoring' Switched to a new branch 'refactoring' $ git branch main * refactoring
ファイルの変更が終わったらadd,commitしてpushする。
コミットメッセージに#1(issue番号)をつけることでcommitがGitHub上のissueと紐づく。
つけ忘れてcommitしてしまったら、
$ git commit --amend -m 'clean: formとentityの分割 #1'
--amend
オプションでコミットメッセージを修正できる。
コミットメッセージ書き方
- fix:バグ修正
- hotfix:クリティカルなバグ修正
- add:新規(ファイル)機能追加
- update:機能修正(バグではない)
- change:仕様変更
- clean:整理(リファクタリング等)
- disable:無効化(コメントアウト等)
- remove:削除(ファイル)
- upgrade:バージョンアップ
- revert:変更取り消し
$ git add /Users/owner/git/menta/springboot_docker/springboot-dev-docker-template-master/volumes/app/src/main/java/com/example/demo/entities #メッセージにissue番号をつける $ git commit -m 'clean: formとentityの分割 #1' [refactoring 7765203] clean: formとentityの分割 #1 2 files changed, 27 insertions(+) $ git push
pushしたらGitHub上でプルリクエストを作成する。
問題がなかったらマージする。
issueをcloseしブランチを削除
commit時の#1がissueと紐付いてることがわかる。
mainブランチへ移動しリモートからpullしてローカルへ取得
$ git checkout main Switched to branch 'main' $ git pull origin main
checkout時のエラー
$ git checkout main error: Your local changes to the following files would be overwritten by checkout: volumes/app/src/main/java/com/example/demo/.DS_Store Please commit your changes or stash them before you switch branches. Aborting
エラー: 次のファイル/Java/com/example/demo/.DS_Storeは更新されてるので
チェックアウトにより上書きされます。
ブランチを切り替える前に、commitかstashしてください。
commitすればOKだがしないで退避したい場合はstashを使う。
$ git stash Saved working directory and index state WIP on refactoring: 64920ff Merge branch 'main' of https://github.com/meo2718/crud_app_java into refactoring $ git checkout main Switched to branch 'main'