Skip to content

Instantly share code, notes, and snippets.

@aq2bq
Last active July 19, 2017 10:12
Show Gist options
  • Select an option

  • Save aq2bq/5925009 to your computer and use it in GitHub Desktop.

Select an option

Save aq2bq/5925009 to your computer and use it in GitHub Desktop.
StudyingGit:復習メモ
# ブランチ
## リモートのgitブランチをローカルにチェックアウトする
$ git checkout -b branch_name origin/branch_name
## - http://sessan.hatenablog.com/entry/2012/11/04/132746
## masterブランチに加えられた変更をトピックブランチへマージする
$ git checkout topic_branch
$ git merge master
## - http://d.hatena.ne.jp/inouetakuya/20130602/1370173582
## リモートのタグをチェックアウトする
$ git checkout -b 1.6 refs/tags/v1.6
## - http://d.hatena.ne.jp/kanonji/20110304/1299211488
# - - -
# やり直し系
## addする前に戻す
$ git rm --cached .
## addしたファイルを取り消す(更新内容は維持される)
$ git reset HEAD file_name
## addしたファイルを取り消す(更新内容もろとも取り消す)
$ git checkout file_name
## ソフトリセット:コミットを取り消す(更新内容は維持される)
$ git reset --soft HEAD^
$ git reset --soft commit_id
## ハードリセット:コミットを取り消す(更新内容もろとも取り消す)
$ git reset --hard HEAD^
$ git reset --hard commit_id
## ハードリセットしたコミットを復旧する
$ git reflog
### => ... HEAD@{n}: ...
$ git reset --hard HEAD@{n}
## コミットメッセージを直す
$ git commit --amend
## - http://tech.basicinc.jp/Git/2013/06/15/git_command/
## - http://www.slideshare.net/TomohikoHimura/git-22237343
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment