1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

gitチートシート

Posted at

自分の作業フローに合わせたチートシート

0. 前提

ブランチ構成

main 
 L dev
    L feat1 ←これを作って、編集して、マージする想定
    L  :
    L featN

1. ブランチ作成

# 1. ブランチを作成
git branch feat1

# 2. 作成したブランチに移動
git checkout feat1

2. コード編集

これは普通にコーディングするだけ。
自動でVSCodeの「ソース管理」GUIに反映される。

3. コミット

VSCodeの「ソース管理」GUIで作業する。
・変更をステージング(add .)
・コミットメッセージを生成(生成AI)
・コミット
・プッシュ

4.マージ

VSCodeのGUI操作が覚えきれないので、コマンドで。

4.1. 他人のfeat1とマージ

# 1. リモートの最新状態を取得(フェッチ)
git fetch origin

# 2. feat1 に移動
git checkout feat1

# 3. リモートブランチの変更をマージ
git merge origin/feat1

# 4. リモートにプッシュ
git push origin feat1

コンフリクトがあれば、VSCodeの「ソース管理」GUIに表示される。クリックして差分を目視確認して解消する。

4.2. devにマージ

# 1. リモートの最新状態を取得(フェッチ)
git fetch origin

# 2. dev に移動
git checkout dev

# 3. リモートブランチの変更をマージ
git merge origin/feat1

# 4. リモートにプッシュ
git push origin dev

その他

ブランチ一覧を表示

git branch -r
1
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?