不用每次输入账号和密码的方法
git config credential.helper store
git push https://github.com/repo.gitUsername for ‘https://github.com‘:
Password for ‘https://USERNAME@github.com‘:
这样的话只需要第一次输入密码,后面就会记住了。 但是它有个致命的缺点,
This answer is missing a warning about the store credential helper storing the password on disk unencrypted.
对单个 repo 设置 user.name 和 user.emailaddress
如果有很多个 github 账号, 可以对本地不同的 repo 设置不同的 github account
下面这样是 global 的设置
git config –global user.name “Mona Lisa”
去掉 –global,只对本地有效
git config user.name “Mona Lisa”
如何把 branch name 放在 bash prompt 前面
在 ~/.bash_profile 里写入
parse_git_branch() {
git branch 2> /dev/null | sed -e ‘/^[^]/d’ -e ‘s/ (.*)/ (\1)/’
}
export PS1=”\u@\h [\033[32m]\w[\033[33m]$(parse_git_branch)[\033[00m] $ “
source 后就可以了