inch-blog

Welcome to Inch-blog ! Home is a place where you can read mainly technical articles. LIFE is mainly about my personal life.

github コマンド

リモートリポジトリ関連

リモートリポジトリの確認
git remote -v
リモートリポジトリの追加
git remote add [name] [URL]
リモートリポジトリの削除
git remote rm [name]
リモートリポジトリの URL の変更
git remote set-url origin [URL]
リモートリポジトリの名前を変更 name1 → name2
git remote rename [name1] [name2]
デフォルトのリモートを確認する方法
git branch -vv

すべてのローカルブランチについて一括で確認したい場合は --all オプションを使用すれば可能です.

git branch -vv --all

# git branch -vv -a でも可能 
デフォルトのリモートを変更する方法
git push -u origin main

-u をつけて実行すると該当ブランチのデフォルトリモートが変更されます.

あるいは以下の方法でも可能です.

git branch -u github main

sub module 関連

sub module の pull 初回
git submodule update --init --recursive
sub module の pull 2 回目
git pull --recurse-submodules

git ignore のキャッシュを削除する方法

ファイル全体を削除する場合
git rm -r --cached . 
ファイルを指定して削除する場合
git rm -r --cached [ファイル名]

編集内容を取り消す方法 (add する前)

git checkout [ファイル名]