0
0

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の使い方めも📝

Last updated at Posted at 2025-05-29

Gitの流れをまとめてみた

ただの自分用のメモ

① main ブランチを最新にする

bash
git checkout main
git pull origin main

リモートのコードに自分のローカルを合わせる。

② 作業用のブランチを作る(=featureブランチ)

bash
git checkout -b feature/ログイン機能

ブランチを切って作業。

③ コミット

bash
git add .
git commit -m "ログインフォームを作成"

④ GitHub にプッシュ(初回は -u をつける)

bash
git push -u origin feature/ログイン機能

⑤ GitHub上でプルリクをする

okが出たら…

⑥ ローカルに戻って main を更新

bash
git checkout main
git pull origin main

⑦ 古い作業ブランチは削除(使い終わったら)

bash
git branch -d feature/ログイン機能
git push origin --delete feature/ログイン機能

リモートとローカルのブランチを削除している。

もしGitHub上でリモートのブランチを削除しても git branch -aに残っている場合、

bash
git fetch --prune

を実行すると追跡情報が削除される。

次の作業

bash
git checkout main
git pull origin main
git checkout -b feature/次の作業

mainブランチに移動して、リモートからのデータを取得してローカルに取り込み、次のブランチを作成。

その他

リモートリポジトリの確認

bash
git remote -v

gitのログを視覚的にみやすくするコマンド

bash
git log --oneline --graph --decorate
0
0
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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?