GitとGitHubを体験しながら身につける勉強会

9/18 に、GitとGitHubを体験しながら身につける勉強会に参加してきました。

USBメモリにぶち込んだ Ubuntu の初実践(?)。

  • merge とか使わない。rebase 使う。 (by bleis)
  • .bashrc の PS1 に $(__git_ps) で現在のブランチを表示できる
    • 自分の .bashrc もこんな感じにした (Ubuntu)↓
#if [ "$color_prompt" = yes ]; then
#    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
#else
#    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
#fi  
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\] : \[\033[01;34m\]\w$(__git_ps1)\[\033[00m\]
\$ '
PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w$(__git_ps1)\[\e[0m\]\n\$ '
  • git cat-file -p ハッシュ で、ハッシュの指す中身を見る
    • 中身
      • commit
        • tree
          • tree
            • ディレクトリ
          • blob
            • ファイル
        • parent (commit)
          • 一個前のコミット (ある場合のみ)
  • git push = git push origin master
    • master から辿れるコミットのみ push
    • git push (リモート名) (ブランチ名)
  • git reset
    • git reset
      • インデックスを戻す。ワーキングディレクトリはそのまま。
    • git reset --hard
      • インデックス、ワーキングディレクトリを戻す。
      • 今のブランチごと移動する感じ
  • git のマージ
    • (必要なら rebase して、) git reset --hard でマージ
      • fast forward マージの代わりに、移動
      • やってることは同じ
  • gitconfig
    • 自分の .gitconfig はこんな感じ ↓ (名前/メールアドレス部分省略)
[color]
	ui = auto
[core]
	editor = vim
[alias]
	log-all = log --graph --all --color --pretty='%x09%h %cn%x09%s %Cred%d%Creset'

log-all は git logで、gitk --all くらい情報ほしい から頂きました。

  • git add -p
    • ファイルの一部をステージするとかできる
  • git stash
    • 一時的に他のブランチに移って移動できる
  • bleis
    • いきなり講師を振られて難なくこなす bleis さんマジ bleis!


いろいろやった場所 : rf0444's hoge at master - GitHub