初期設定
Gitリポジトリを作成するコマンド
git init
リモートリポジトリの情報を登録
git remote add origin https://github.com/<account>/<repository>.git
基本操作
インデックスに追加する
git add <filename>
変更結果をローカルリポジトリにコミットする
git commit -m "comment"
確認
git status
リモートリポジトリに反映
git push origin master
リモートリポジトリに反映(強制)
git push -f origin master
リモートのリポジトリからデータをプルする
git pull origin master
ブランチを切り替えるときに使用する
git checkout <branch name>
ファイルを移動/リネームする
git mv <file name before> <file name after>
ファイルを削除する
git rm <file name>
ファイルの変更履歴を見る
git log -p <file name>
登録されているリモートリポジトリの情報を確認する
git remote -v
gitサブモジュールの状態を確認
git submodule status
gitサブモジュールのコミットのサマリを確認
git submodule summary
gitサブモジュールの削除
git submodule deinit -f <追加したサブモジュール> git rm -f <追加したサブモジュール>
応用操作
- 変更したファイルを全てコミットする
git add -A git commit
or
git commit .
その他
バージョン確認
git --version
EOF