For the importance of commit-logs to committed-changes-review, logs are frequently checked. Effective and beautiful logs would double the efficiency. Then comes the question, how? One way is to making rules. Rules and convention makes logs lawful. The other way is to making the style. Beautiful styles makes logs delightful.
Angualr Convension is a popular and proper convention for this job. It regularizes logs with 'type-scope-msg' convention. Just like those below. Click-here-to-see-detail
git log
gives format-parameters to show what message you want to see in style you want.
- Cmd behind is a popular log cmd:
git log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --graph
It shows logs like this:
It shows commit-hash-code, branch-position, commit-head, relative-commit-time, commit-author. This cmd fulfills most logs checking situation.
- Then you may want to do this faster.
Here**!** Use this cmd below.
git config --global alias.lg "log --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(blue)<%an>%Creset' --abbrev-commit --graph"
Config it into your global-git-configuration and make it happens for all git project on your current usr account.
Then check it with git lg
:
You may see this configuration though this cat ~/.gitconfig
.
Technically, you can just edit this file and make it happens.
You may have more than one git account(one for github and one for work), then you need use different account on different push
and pull
. You can config your .bash_profile for a faster account switching here:
- firstly, make sure you've got one ssh keypair, and work properly well communicating with remote git code server.
- secondly, you generate a new ssh keypair with new user.email using
ssh-keygen
and save this key with different file. Then you've got a second key/user to communicate with git server. sh-add -l
to list keys you local ssh client keeping. If your new key not in this client, justssh-add $secret-key
to add it.- third, you add this new pub-key to the github/gitlab settings. Then remote git server know your new key/user. you can clone code with authority.
- Fouth, config what user you want to use to
git pull/push
on each project. There are two file doing this job, global~/.gitconfig
and local.git.config
. I suggest you use your work user as global, which you put it in global file; and side project using this new user, which you can put it in project local.git/config
file. you can do it quicker and add to bash alias.alias gitme='git config user.name "Szymon"; git config user.email [email protected]'
to config your own github account on this git project(Seeing./.git/config
file for more info.)alias gitwork='git config --global user.name "$workname"; git config --global user.email $workmail'
to config your work account on this project(Seeing~/.gitconfig
file for more info.)
😀Now you can just use gitme
and gitwork
to switch account. And you can check it in ~/.gitconfig.
git config
- Get and set repository or global optionsgit config --global core.editor vim
set default editorgit config $key $value
set configgit config $key
get configgit config --list
show all config in$key=$value
listgit help <verb>
,git <verb> --help
orman git-<verb>
show static text help
git config --global http.proxy 'socks5://127.0.0.1:1086' # 以实际端口为准,mac默认是1086
git config --global https.proxy 'socks5://127.0.0.1:1086' # 以实际端口为准,mac默认是1086