LoginSignup
20
20

More than 5 years have passed since last update.

Gitをインストールしたらやること

Last updated at Posted at 2014-03-14

Git settings


メールアドレスとユーザ名設定

$ git config --global user.name <userName>

$ git config --global user.email <mailAddress>

カラフル設定

$ git config --global color.ui auto

コミットメッセージのテンプレートを設定

$ git config --global commit.template $HOME/.gitmessage.txt

エイリアス設定

$ git config --global alias.co checkout

とかでも出来るけど、めんどいので

.gitconfigを直接編集してwq

コミットログ編集用エディタをviに変更

$ git config --global core.editor 'vi -c "set fenc=utf-8"'

以上を適用した .gitconfig は以下

    [user]
        email = <mailAddress>
        name = <userName>

    [color]
        ui = auto

    [commit]
        template = /home/<userName>/.gitmessage.txt

    [alias]
        lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
        lga = log --graph --all --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
        co = checkout
        br = branch
        ci = commit
        st = status

    [core]
        editor = vi -c \"set fenc=utf-8\"

プロンプトに現在のブランチ名を表示させる

  • .bashrcに以下を追加
    $ vi $HOME/.bashrc
    # git show branch name
    PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ '
  • 反映
    $ source $HOME/.bashrc

参考

20
20
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
20
20