gitk

GUIなlog, diffビュワー。コマンドを覚えるのも重要だが、さくっと見るだけならかなり便利。branch, mergeの様子もよくわかる。CUIでは「git log --graph」を使用。マニュアルは以下から。

HEAD

  • HEAD
  • HEAD~ or HEAD~1
  • HEAD~~ or HEAD~2
  • HEAD~~~ or HEAD~3
  • HEAD~~~~ or HEAD~4
  • ........

git config

git config --global user.name "Hoge Huga"
git config --global user.email aho@example.com

git remote

git remote -v

check remote URL

git log

git logshow log
git log -p -2shows the diff introduced in each commit and limit output number

git reflog

git reflogshow all changes even though they are not referenced by any branch or tag. E.g git reset --hard HEAD@{2}

git checkout

git checkout -- <file>discard changes (revert in subversion)
git checkout <branch> -- <file>import <file> from <branch>
git checkout <target>change current branch
git checkout <hash>back to certain version of repository
git checkout <hash> <file>back to certain version of file

一時的に以前の状態に戻る:

$ git checkout cea7f5a45fa7d9f29f7ae7cXXXXXXXXX
$ git branch
$ * (no branch)
   master
   unbiased-mapmaking
$ git checkout master

git reset

git reset HEAD <file>unstage file
git reset --hard <hash>back to <hash> (commit deleted)

git branch

git branchget a simple listing of the current branches
git branch -aget a simple listing of all the branches
git branch -vsee the last commit one each branch
git branch <target>make new branch
git checkout <target>switch target branch
git branch -b <target>make new branch and switch it at the same time
git branch -d <target>delete target branch

git cherry-pick

git cherry-pick <SHA1>apply the changes introduced by some existing commits

git merge

git merge <target>merge target branch with the current branch

git show

git show <SHA1>:<target>show target on SHA1 revision
git show <branch>:<target>show target on a branch

git pull

git pullFetch from and integrate with another repository
git pull --rebaseit runs git rebase instead of git merge

git push

git pushUpdate remote refs along with associated objects

git cat-file

git cat-file -p <SHA1>:<target>cat target on SHA1 revision