* HEAD [#e4a0fa1e]
- HEAD~ or HEAD~1
- HEAD~~ or HEAD~2
- HEAD~~~ or HEAD~3
- HEAD~~~~ or HEAD~4
- ........

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

-[[gitk(1) Manual Page>http://www.kernel.org/pub/software/scm/git/docs/gitk.html]]

* git clone [#yf6bc167]

|git clone '''URL''' | clone the git repository |

Example w/ healpy,
 git clone https://github.com/healpy/healpy.git
and you can get
 git clone https://github.com/healpy/healpy.git
 Cloning into 'healpy'...
 remote: Counting objects: 5503, done.
 remote: Compressing objects: 100% (5/5), done.
 remote: Total 5503 (delta 0), reused 1 (delta 0), pack-reused 5498
 Receiving objects: 100% (5503/5503), 15.58 MiB | 10.17 MiB/s, done.
 Resolving deltas: 100% (3006/3006), done.
 Checking connectivity... done.
 [chinoney@yMacBookPro:~ ] $ ls healpy
(not healpy.git)

* git config [#i482f886]
- https://git-scm.com/docs/git-config

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

* git remote [#f7fb3cf1]
 git remote -v

check remote URL

* git log [#b103aedf]
- https://git-scm.com/docs/git-log

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

* git reflog [#b103aedf]
- https://git-scm.com/docs/git-reflog

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

* git checkout [#z66fdea1]
- https://git-scm.com/docs/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)
 $ git checkout master

* git reset [#e5f4700f]
- https://git-scm.com/docs/git-reset

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

* git branch [#z1c894b5]
- https://git-scm.com/docs/git-branch

|git branch | get a simple listing of the current branches |
|git branch -a | get a simple listing of all the branches |
|git branch -v | see 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 branch <target> origin/<target> | pull a target branch |
|git pull origin <target> | pull a target branch and ''make a merge'' (dangerous) |

* git cherry-pick [#a4a30795]
- https://git-scm.com/docs/git-cherry-pick

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

* git merge [#g43168c8]
- https://git-scm.com/docs/git-merge

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

* git show [#f64a9798]
- https://git-scm.com/docs/git-show

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

* git pull [#f05de43f]
- https://git-scm.com/docs/git-pull

|git pull | Fetch from and integrate with another repository |
|git pull --rebase | it runs git rebase instead of git merge |

* git push [#ue6b575f]
- https://git-scm.com/docs/git-push

|git push | Update remote refs along with associated objects |

* git cat-file [#l54aca18]
- https://git-scm.com/docs/git-cat-file

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

* tips [#wadbf309]
** configure a global ignore setup [#ve66f519]

 git config --global core.excludesfile ~/.gitignore_global



** make a new branch from master before merged/pushed and revert the original branch to origin [#v6a04d57]

 git status
 # On branch master
 # Your branch and 'origin/master' have diverged,
 # and have 64 and 6 different commit(s) each, respectively.

Check how much different btw HEAD and origin/master
 git log origin/master..HEAD
 git show origin/master..HEAD

Make a new branch from HEAD
 git checkout -b new_branch

Then delete the master
 git branch -d master
 git branch -D master

and download the master from the origin
 git fetch
 git checkout master

Push the new branch if you want
 git push -u origin new_branch