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

【初回セットアップ (一度だけ)】

  1. GitHub からリポジトリをクローン
    git clone https://github.com/kmatsumoto630823/zBot.git
    
  2. ディレクトリに移動
    cd zBot
    
  3. develop ブランチを作成
    git checkout -b develop
    
  4. GitHub に develop をアップロード
    git push origin develop
    

main を最新にして develop に反映(共同開発の場合はNG)】

  1. main を最新にする
    git checkout main
    git pull origin main
    
  2. develop を main の状態に完全一致させる
    git checkout develop
    git reset --hard main
    git push origin develop --force
    

【開発開始 (作業のたびに)】

  1. develop を最新にする
    git checkout develop
    git pull origin develop
    
  2. 変更を加える(いずれか)
    • 🖊 コードを編集
      code .
      
    • 🔄 パッケージを更新(必要な場合)
      npm update
      
  3. 変更をGitに記録
    git status
    git add .
    git commit -m "変更内容の説明"
    
  4. GitHub にアップロード
    git push origin develop
    

main に反映 (動作確認後)】

  1. develop を最新にする
    git checkout develop
    git pull origin develop
    
  2. main に移動してマージ
    git checkout main
    git merge develop
    git push origin main
    

【まとめ】

ステップ やること コマンド
初回セットアップ GitHub からリポジトリを取得 git clonegit checkout -b develop
main** を develop に反映** main を最新にして develop をリセット git checkout maingit pullgit checkout developgit reset --hard maingit push origin develop --force
開発開始 develop を最新にして編集 git checkout developgit pull
変更を加える コード編集 または パッケージ更新 code . または npm update
変更を記録 Git に記録 & コミット git add .git commit -m "変更内容"
GitHub にアップ develop にプッシュ git push origin develop
main** に反映** developmain にマージ git checkout maingit merge developgit push origin main

💡 基本は「develop で開発」→ 「GitHub に push」→ 「問題なければ main にマージ」の流れでOK。
💥 git pull** の前に「変更を commit or stash」すると安全!**

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