git操作
# git初期設定
sudo apt-get install -y git
ssh-keygen -t rsa -b 4096
>パスワード
ssh -T git@github.com
git config --global user.email "メールアドレス"
git config --global user.name "名前"
# GoogleSourceRepositories運用
## 初回
gcloud init
gcloud source repos clone レポジトリ名 --project=プロジェクトID
cd レポジトリ名
# GitHub運用
## 初回
git clone git@github.com:レポジトリ名.git
cd レポジトリ名
## 毎回
git switch master
git pull
git switch dev/開発ブランチ名
## 開発ブランチ作成
git switch --create dev/開発ブランチ名
git switch -c dev/開発ブランチ名
## 開発ブランチ参加
git switch --create dev/開発ブランチ名 origin/dev/開発ブランチ名
git switch -c dev/開発ブランチ名 origin/dev/開発ブランチ名
## add,update,fix
git add ファイル名
git commit --message "[コミット種別] バックログ番号 変更内容"
git push origin dev/開発ブランチ名
git add -A
git commit -m "[コミット種別] バックログ番号 変更内容"
git push origin dev/開発ブランチ名
## remove
git rm ファイル名
git commit --message "[remove] バックログ番号 変更内容"
git push origin dev/開発ブランチ名
# TIPS
## 状態確認
git status
## レポジトリ内の全ての変更を一括追加する
git add --all
git add -A
## レポジトリ内の全ての変更を一括追加する(新規追加ファイルは対象外)
git add --update
git add -u
## ディレクトリ内の全ての変更を一括追加する
git add .
## git add前のファイルの変更を戻す
git restore ファイル名
## git add後のファイルの変更を戻す
git restore --staged ファイル名
git restore -S ファイル名
## コミット番号を確認する
git log --oneline
git log --graph
## ファイルをコミット番号の状態にする
git restore --source コミット番号 ファイル名
git restore -s コミット番号 ファイル名
## ディレクトリ内をコミット番号の状態にする
git restore --source コミット番号 .
git restore -s コミット番号 .
## masterブランチにコミットしてしまった
git rebase 1個前のコミット番号
git switch --create dev/開発ブランチ名
git cherry-pick 該当コミット番号
git push origin dev/開発ブランチ名
## ローカルブランチ一覧
git branch
## リモートブランチ一覧
git branch --remotes
git branch -r
## ブランチ一覧
git branch --all
git branch -a
## マージ済みブランチの削除
git branch --delete dev/開発ブランチ名
git branch -d dev/開発ブランチ名
## マージされていないブランチの削除
git branch --delete --force dev/開発ブランチ名
git branch -D dev/開発ブランチ名