首页 > 其他 > 详细

Git

时间:2021-05-14 15:14:03      阅读:20      评论:0      收藏:0      [点我收藏+]

Git

1、关于

https://gitee.com/all-about-git

2、配置

2.1、基本

# 查看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"

2.2、免密

# 生成密钥,回车
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‘

3、命令

3.1、操作分支

# 列出所有本地分支
git branch
# 列出所有远程分支
git branch -r
# 列出所有本地、远程分支(显示结果:带*且是绿色的为当前本地分支,红色的为远程分支)
git branch -a

# 切换到分支
git branch 分支名

# 合并指定分支到当前分支
git merge 指定分支名

# 新建一个本地分支
git branch 分支名
# 新建一个本地分支,并切换到该分支
git checkout -b 分支名
# 删除本地分支
git branch -d 分支名

3.2、提交、更新

# 查看修改了哪些文件
git status
# 添加所有代码到暂存区(提交部分:git add xxx.java)
git add .
# 提交代码到本地库
git commit -m "提交信息"
# 提交到远程git仓库的 master 分支
git push origin master

# 更新本地 master 分支
git pull origin master

Git

原文:https://www.cnblogs.com/lixunsheng/p/14765799.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!