git使用
1. git使用
1.1. 如何将企业中仓库代码拉取到本地
git从gitlab拉取最新的代码到本地
为GitLab帐号添加SSH keys并连接GitLab
使用Git拉取GitLab上的项目
-
安装Git
(安装步骤参考https://www.cnblogs.com/xwgcxk/p/9209237.html) -
从管理员手中拿到用户名、邮箱、密码
假设用户名为: itcats_cn
邮箱为itcats_cn@itcats.cn
密码为12345678 -
初始化git信息(在右键Git Bash输入以下命令)
- git config --global user.name 'itcats_cn'
- git config --global user.email 'itcats_cn@itcats.cn'
-
检查并且配置公钥(SSH)
- 检查ssh的方法
- 查看本机 ssh 公钥,生成公钥
- 检查是否存在id_rsa.pub文件,若已经存在id_rsa.pub文件,则表示存在
- 可以通过如下命令进行查找公钥:
- 打开你的 git bash 窗口
- 进入 .ssh 目录:cd ~/.ssh
- 找到 id_rsa.pub 文件:ls
- 查看公钥:cat id_rsa.pub 或者 vim id_rsa.pub

- 若不存在这个文件,使用命令"ssh-keygen -t rsa -b 4096 -C "your_email@example.com" ## your_email@example.com是gitlab的账号。(plus:直接按Enter即可,密码可输入可不输入)
- 查询全局的配置 git config --list
- 检查ssh的方法
-
复制公钥到gitlab

-
使用git clone xxxxxxx.git 从远程仓库拉取代码
1.2. 本地代码有变更如何提交到仓库
- 本地的代码项目,如何上传到git仓库中
git config --global user.name "xxxxx"
git config --global user.email "xxxxxxxx@xxxxx.com"

浙公网安备 33010602011771号