
Ubuntu git 设置(一)
1、安装 gitsudo apt install git2、安装 gitksudo apt install gitk3、设置用户名、邮箱和密码git config --global user.name "名字"git config --global user.email "邮箱"4、验证公钥ssh-keygen -C '邮箱' -t rsa一路回车,使用命令cd ~/.ssh进入~/.ssh文件夹
·
1、安装 git
sudo apt install git
2、安装 gitk
sudo apt install gitk
3、设置用户名、邮箱和密码
git config --global user.name "名字"
git config --global user.email "邮箱"
4、验证公钥
ssh-keygen -C '邮箱' -t rsa
一路回车,使用命令 cd ~/.ssh
进入~/.ssh
文件夹,输入 gedit id_rsa.pub
打开id_rsa.pub
文件,复制其中所有内容
5、设置 git 命令自动补全
sudo vim /etc/bash.bashrc
将
#enable bash completion in interactive shells
# if ! shopt -oq posix; then
# if [ -f /usr/share/bash-completion/bash_completion ]; then
# . /usr/share/bash-completion/bash_completion
# elif [ -f /etc/bash_completion ]; then
# . /etc/bash_completion
# fi
# fi
去掉注释
#enable bash completion in interactive shells
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
运行 sudo source /etc/bash.bashrc 生效
6、设置 git 显示分支名称
sudo vim /etc/bash.bashrc
在文末添加
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\W$(git_branch)\[\033[00m\]\$ '
#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$(git_branch)\$ '
#PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
git_branch()
{
branch=`git rev-parse --abbrev-ref HEAD 2>/dev/null`
if [ "${branch}" != "" ]
then
if [ "${branch}" = "(no branch)" ]
then
branch="(`git rev-parse --short HEAD`...)"
fi
echo -e " \033[32m[$branch]\033[0m " #颜色设置
fi
}
保存后运行 source /etc/bash.bashrc 生效
更多推荐
所有评论(0)