目录
git命令在git bash中演示,会用到一些Linux命令。
1.Git环境配置
1.1下载
Git下载地址:https://git-scm.com/download
傻瓜式安装就可以了。
安装结束后,桌面鼠标右键,包含Git GUI here 和 Git bash here就是安装成功了。
Git GUI : Git 提供的图形界面工具
Git Bash : Git 提供的命令行工具 (相当于linux窗口)

安装好以后首先设置用户名称和email地址,每次提交都会使用用户信息。因为每次代码修改以及修改内容都是要记录为版本的,所以用户信息是必要的。
1.2配置
1.2.1基本配置
-
打开Git Bash
-
设置用户信息
cs
git config --global user.name "your name"
git config --global user.email "your email"
3.查看用户信息
cs
git config --global user.name
git config --global user.email

1.2.2常用指令配置别名
这个在学习linux的时候就已经学习过了,主要就是部分指令参数非常多,输入很麻烦就需要使用别名简化。
- 打开用户目录创建 .bashrc 文件
如果系统不允许.开头的文件那么打开git bash 使用 touch创建 ~/.bashrc

然后到当前用户根目录找到并打开:

2.配置以下内容
bash
# 输出git提交日志
alias git-log='git log --pretty=oneline --all --graph --abbrev-commit'
# 输出当目录所有文件 以及 基本信息
alias ll='ls -al'
- 打开git bash 执行source ~/.bashrc
4.解决输入汉字会乱码的问题
bash
git config --global core.quotepath false
然后打开 {git_home}/etc/bash.bashrc 文件最后加入({git_home}这就是git的安装目录)
bash
export LANG="zh_CN.UTF-8"
export LC_ALL="zh_CN.UTF-8"
1.2.3获取本地仓库
如果要使用Git对代码进行版本控制,首先要获取本地仓库。
1.创建一个空目录
2.进入目录 右键打开bash 执行 git init初始化

3.如果创建后存在.git目录 那就是创建成功了
