Closed3
共同開発で使いそうなgitコマンドを適当にまとめる
![knot](https://res.cloudinary.com/zenn/image/fetch/s--WmFiLTL2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/8b31060d56.jpeg)
初回のクローンからプッシュまで
- リポジトリのクローン
$ git clone リポジトリのURL
- ブランチの作成
$ git branch 任意のブランチ名
- ブランチの移動
$ git switch 移動先のブランチ名
ブランチの作成と移動を1回でやる方法
$ git checkout -m ブランチ名
- 変更のステージング
$ git add . #このコマンドはすべてのファイルをaddするよ
$ git add hoge.txt #このコマンドはhoge.txtだけをaddするよ
- addした内容のコミット
$ git commit -b "任意のコミットメッセージ"
- コミットした内容のプッシュ
$ git push origin プッシュ先のブランチ名
![knot](https://res.cloudinary.com/zenn/image/fetch/s--WmFiLTL2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/8b31060d56.jpeg)
2回目以降の作業開始時にすること
developブランチからプル
$ git pull origin develop
![knot](https://res.cloudinary.com/zenn/image/fetch/s--WmFiLTL2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_70/https://storage.googleapis.com/zenn-user-upload/avatar/8b31060d56.jpeg)
作業を終えるとき、またはキリがいいときにやること
作業したブランチで
- 変更のステージング
$ git add . #このコマンドはすべてのファイルをaddするよ
$ git add hoge.txt #このコマンドはhoge.txtだけをaddするよ
- addした内容のコミット
$ git commit -m "任意のコミットメッセージ"
- コミットした内容のプッシュ
$ git push origin プッシュ先のブランチ名
このスクラップは2022/07/01にクローズされました