Git よく使う命令(随時更新)
ラストコミットをUndo/撤回する
git reset HEAD~
一つcommitを別のブランチに反映する
git cherry-pick <COMMIT_ID>
Commitを無しにする
git revert <COMMIT_ID>
# ラストCommitを消すわけではない、ただ新しい Commitを作って変更を削除した状態に戻す
# めったに使うな
Rebase VS merge
Rebase VS merge
Rebase vs merge
マルチアカウントでpublic keyをそれぞれセットする方法
# .ssh/config
# first
Host github.com-<git repo master account name>
HostName github.com
User git
IdentitiesOnly yes
IdentityFile ~/.ssh/<first public key>.pem
# second
Host github.com-<git repo master account name>
HostName github.com
User git
IdentitiesOnly yes
IdentityFile ~/.ssh/<second public key>.pem
# ハマるどころ
# remoteのurlがssh/configのHOSTと違ったらむしされるので各repoのurl修正が必要
# 解決策1
git clone git@github.com:<git repo master account name>/<repo>.git
を最初から
git clone git@github.com-<git repo master account name>:<git repo master account name>/<repo>.git
で持ってくる
# 解決策2
# repo/path/.git/config
[remote 'origin']
url = git@github.com:<git repo master account name>/<repo>.git
↓ に変更
[remote 'origin']
url = git@github.com-<git repo master account name>:<git repo master account name>/<repo>.git
error: src refspec mas does not match any.
git initでcommitしてない
git add .
git commit -m'???'
git push origin master
git gc (garbage collection)
.git/objectsに情報がたまり過ぎている時に役に立つコマンド
参考
git checkout ignore rules
git status --ignored -s
or
git clean --ndX