OTRS#25645についてフィックスする。featureを使って修正してみる。実際に開発していると起きそうなことを実際に試してみる。
masterからfeature-25645を作成する
git checkout -b feature-25645
ここでいったん変更を加えてコミットする。以下のエラーはmasterとfeatureブランチに違いがある場合だけ出る。
feature-25645ブランチをチェックアウトする
$ git checkout -b feature-25645 Switched to branch 'feature-25645'
feature-25645ブランチを編集する
main.javaを編集した
ここでステージングしないでmasterにもどってみる。
$ git checkout master error: Your local changes to the following files would be overwritten by checkout: readme.md Please, commit your changes or stash them before you can switch branches. Aborting
ステージングエリアに追加する
$ git add readme.md
マスタに戻ってみる
$ git checkout master error: Your local changes to the following files would be overwritten by checkout: readme.md Please, commit your changes or stash them before you can switch branches. Aborting
変更をコミットする
$ git commit -m "fixed" [feature-25645 4297f2f] fixed 1 file changed, 2 insertions(+)
マスタにもどる
$ git checkout master Switched to branch 'master'
feature-25645ブランチで編集を始めると、コミットを完了するまではmasterブランチにもどれない。しかし同時進行で作業を進める場合にはワーキングツリーあるいはステージングエリアの変更が終わったタイミングで別のブランチにも取りたいときがある。どうやって対処するのか。