LoginSignup
1
2

More than 5 years have passed since last update.

Git よく使う命令(随時更新)

Last updated at Posted at 2017-02-28

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

From

What is git flow

Git tag vs branch

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2