1
1

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-01

概要

gitの使い方について、すぐ忘れてしまうため、
自分用のメモとなります。

ブランチの作成からマージするまでの一連の流れをまとめました。

ブランチの新規追加後、切替する方法

git branch
ローカルブランチの一覧を表示
git checkout -b test1
test1のブランチを追加し、切り替え

作業内容の保存方法

git branch
ローカルブランチの一覧を表示
git add --all
修正したファイル、削除したファイル、新規に追加したファイルなど
変更のあった全てのファイルをステージングエリアに追加
git commit -m "htmlブランチテスト"
ステージングしたファイルをコミットすることでバージョンの履歴を追加
-m:メッセージ(message)の略。
⇒"変更した理由を記載"
git push origin HEAD 
今いるブランチからリモートレポジトリのoriginにプッシュ(アップロード)する

他のブランチからデータを統合する方法

git checkout main
統合したいブランチに切り替え
git branch
ローカルブランチの一覧を表示
git pull origin main
最新の状態に更新
git merge test1 
指定したブランチの変更を現在のブランチに統合

参考文献

https://www.sejuku.net/blog/71612
https://backlog.com/ja/git-tutorial/stepup/07/
https://qiita.com/yunano/items/f3133ea64efed762df2f
https://qiita.com/chihiro/items/e178e45a7fd5a2fb4599
https://qiita.com/takata2022/items/7222c856ac3f13a3f4e8
https://qiita.com/takuyanin/items/8d5226fd5834e6ebc564
https://qiita.com/shimotaroo/items/ed08d76447144d566637

1
1
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
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?