https://gitee.com/all-about-git
# 查看git系统、用户配置
git config -l
# 查看git系统配置
# Windows物理文件位置:Git安装目录\etc\gitconfig
git config --system --list
# 查看git用户配置
# Windows物理文件位置:C:\Users\用户登录名\.gitconfig
git config --global --list
# 添加配置
git config --global user.name "MovingBricks_Lee"
git config --global user.email "MovingBricks_Lee"
# 生成密钥,回车
ssh-keygen -t rsa
# 复制公钥内容(非root:cat /home/登录名/.ssh/id_rsa.pub)
cat /root/.ssh/id_rsa.pub
# gitlab
个人中心 -> Preferences -> SSH密钥 -> 粘贴
# 若还需要输入密码,解决方法:
# 长期存储密码
git config --global credential.helper store
# 设置记住密码(默认:15min)
git config --global credential.helper cache
# 自定义时间记住密码(单位:s)
git config credential.helper ‘cache –timeout=3600‘
# 列出所有本地分支
git branch
# 列出所有远程分支
git branch -r
# 列出所有本地、远程分支(显示结果:带*且是绿色的为当前本地分支,红色的为远程分支)
git branch -a
# 切换到分支
git branch 分支名
# 合并指定分支到当前分支
git merge 指定分支名
# 新建一个本地分支
git branch 分支名
# 新建一个本地分支,并切换到该分支
git checkout -b 分支名
# 删除本地分支
git branch -d 分支名
# 查看修改了哪些文件
git status
# 添加所有代码到暂存区(提交部分:git add xxx.java)
git add .
# 提交代码到本地库
git commit -m "提交信息"
# 提交到远程git仓库的 master 分支
git push origin master
# 更新本地 master 分支
git pull origin master
原文:https://www.cnblogs.com/lixunsheng/p/14765799.html