Contents
ローカルリポジトリのコード取得
mkdir ディレクトリ名
cd ディレクトリ名
git clone URL
git checkout (切り出し元として指定したい)ブランチ名
git checkout -b 新しいブランチ名
リモートリポジトリへのプッシュ
git rebase master //最初にrebaseしておくことでコンフリクトを防ぐ
git add addしたい内容
git commit
git push
一度pushしたファイルを後から.gitignoreに追加
vim .gitignore
git rm -r --cached . //キャッシュ削除
git add & commit & push
直前のcommitの取り消し
git log //戻したい地点のcommit idを取得
git revert コミットID
参考:terraformファイルpush時の「GH001: Large files detected. You may want to try Git Large File Storage – https://git-lfs.github.com」エラー
上記エラーは、terraform init時に.terraform配下に生成されるファイル容量の大きさがGithubの100MB制限を超過していることが原因。対策は以下。
- 方針1:コミットの取り消し
- .terraformが含まれる全てのコミットを取り消す
- .gitignoreを編集する。
- 再度commit & push
- 方針2:別ブランチの作成
- 別ブランチを切る
- .gitignoreを編集する。
- commit & push
参考:push中にCLIがフリーズするケース
push内容のサイズがgit http buffer以上(※git側のサイズ制限)・100MB(※Githubの上限)以下の場合、エラーメッセージがないままCLIがフリーズする。
対策1:容量が多いディレクトリをcommit対象から外す
対策2:git http bufferの上限値を変更する
変更方法↓(※参考記事)
git config http.postBuffer 524288000
参考:rebaseとは
