LoginSignup
4
3

More than 5 years have passed since last update.

git 使って機能追加とかする時のブランチ操作

Last updated at Posted at 2015-02-19

だいたいのいつものコマンドをメモっとく

準備

とりあえずクローンしてることを前提に
bash
git clone <repo>
cd <repodir>

同期

削除されたブランチとかも同期する

git fetch --prune

何かしら作業したいブランチに移動

git checkout origin/hogehoge

ここでソース眺めたり、動かしたり、だとかする。
いちいちローカルブランチを作らないのが好きです。

変更する時

origin/hogehogeにコミットしない。

git checkout -b feature/hogehoge

変更しちゃってからでも遅くない。

変更はfeature/ブランチなどとにかく別のブランチで。
README.mdとかはそのままやることも許す。

commit

git commit -m "<ticket/issue> hogehoge"

issueトラッキングはしたいよね

push

remote に変更をあげる。

git push origin feature/hogehoge

マージはPullRequestで。

基本は分岐元へPullRequestです。

feature/hogehoge -> hogehoge

誰かにレビューしてもらってマージしてもらうのが良い。
github

同期に戻る。

同期から繰り返し。

PullRequestが can not merge な時。

分岐元からrebaseする。

git rebase origin hogehoge

conflict してたとき

頑張る

終わり。

git pull --rebase origin hogehoge
とかは基本しない流れでやってます。

4
3
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
4
3