Skip to content

git config 小筆記 #12

@JeffKko

Description

@JeffKko

git config 小筆記

init profile

$ git config --global user.name "xxxxx"
$ git config --global user.email "xxxx@xxx.com"

check profile

$ git config --global --list
# or
$ git config -l

ssh key

# check ssh key exist
ls -al ~/.ssh

# gen ssh key
$ ssh-keygen -t rsa -C "xxxx@xxx.com"

# copy public key
$ cat ~/.ssh/id_rsa.pub | clip

alias

$ git config --global alias.co checkout
$ git config --global alias.br branch
$ git config --global alias.ci commit
$ git config --global alias.st status
$ git config --global alias.l "log --oneline --graph"
$ git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"

或者直接編輯設定檔

$ vi ~/.gitconfig
[alias]
    co = checkout
    br = branch
    # 利出 local 與 remote branch
    brav = branch -av
    ci = commit
    st = status
    l = log --oneline --graph
    # 漂亮一點的 log, 而 ls -p 可以看到變動的內容
    ls = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit

check branch

$ git branch

# or
$ git branch -r # 遠端的
$ git branch -a # remote + local

參考

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions