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-02
git checkout -b main        # mainブランチ作成
git push -u origin main

git checkout -b test        # testブランチ作成
git push -u origin test
git checkout test
# 作業 → コミット → push
git add .

【コミットとプッシュの違い】
Aコミット
#変更をローカルのGit履歴に記録する	自分のPCの中だけ
git commit -m "新機能の実装"

Bぷっs
#ローカルの履歴をGitHubなどに送信する	GitHubなどのリモートサーバー
git push origin test
#1.これは「main ブランチに切り替える」コマンドです。
git checkout main

#2.main ブランチの最新の内容を、ローカルの main に取り込む
git pull origin main        

#3.マージ(ここにcommitも含まれる)
git merge test              # testからmainへ

#4.push
git push origin main

-追記-
違うブランチの情報を取得する場合

#GitHub(=origin)にある最新の情報を取得する
git fetch origin
#-bとは、ローカルブランチを作るという意味
git checkout -b test origin/test

上記だとうまくいかず、git側がブランチなのかファイル名なのか迷っている状態だった

テストブランチにブランチ変更

git checkout -b test origin/test --no-guess
0
0
1

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?