0
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 コマンド 業務でつかう主なもの

0
Last updated at Posted at 2023-03-18

業務で使うGitコマンドをまとめました

前提:Git Bushを使用しています。
親ブランチ:main
子ブランチ:sagyou_branch

mainブランチを最新にする

・mainブランチをチェックアウトする。※mainの場合は省略

$ git checkout main

・main最新化

$ git fetch
$ git pull

最新にしたmainブランチを作業ブランチに取り込む

・作業ブランチチェックアウト

$ git checkout sagyou_branch

・mainブランチに取り込む

$ git merge --no-ff main

・マージした作業ブランチ反映

$ git push

mainから作業ブランチを切る時

・mainブランチをチェックアウトする

$ git checkout main

・ブランチ最新化

$ git pull

・作業ブランチ作成

$ git checkout -b sagyou_branch

・作業ブランチをリモートリポジトリに反映

$ git push -u origin sagyou_branch

作業ブランチ削除

・作業ブランチからブランチ削除できないので、mainをチェックアウト

$ git checkout main

・ローカルリポジトリの作業ブランチ削除

$ git branch -d sagyou_branch

・リモートリポジトリの作業ブランチ削除

$ git push origin --delete sagyou_branch

コード修正後のローカルからリモートにプッシュまでの一連コマンド

・修正後のファイルをステージングする

$ git add ファイルパス

・ステージングしたファイルをコメントを残してローカルにコミットする

$ git commit -m "アプリのどこどこを実装"

・リモートにpush

$ git push
0
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
0
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?