1. 下载git安装包安装
2. 查看git安装成功
执行【git --version】命令。如果出现“command not found”或者其他错误提示,说明Git可能没有正确安装,请重新安装Git。
// 查看git版本
git --version
// 查看远程仓库的版本号
git ls-remote 远程仓库地址XXX.git
3. 配置Git的全局设置,包括用户名和邮箱。这些设置将用于标识代码的提交者。
git报Author identity unknown,Please tell me who you are
Author identity unknown 译:作者身份未知
Please tell me who you are 译:请告诉我你是谁
// git报错误信息
Author identity unknown
*** Please tell me who you are.
Run
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
to set your account's default identity.
Omit --global to set the identity only in this repository.
fatal: unable to auto-detect email address (got 'zhaow@ZwzzzLapTop.(none)')
(base)
git上clone项目后无法合并到当前分支的解决办法:
// 在正式使用Git前,需要一些全局设置。分别执行
git config --global user.email "你的邮箱"
git config --global user.name "你的名字"
// 检查Git配置
git config --list
// git全局配置列表
git config --list --global
4. 拉取代码
1) github或gitee上找到远程仓库地址
2) 克隆代码库
// 克隆代码库
git clone 远程仓库地址XX.git
3) 代码–Forked。forked到自己仓库。git远程管理地址用到
4) git远程管理
菜单项 – 管理远程 – 添加远程地址
5) 切换分支
右下角分支 – 选择要切换的分支 【签出】
6) 拉取代码
// 拉取更新操作,箭头朝下,从远程到本地
git pull
7) 添加
// 添加操作,+号图标
git add
8) 提交
// 提交操作,图标对勾,提交自动先 添加、拉取 操作
git commit
9)推送
// 推送操作,箭头朝上,从idea到本地到远程
git push
10) 解决冲突
在多人协作开发中,可能会存在多个人对同一文件进行修改的情况,这时就会产生冲突。当我们执行git pull命令时,如果存在冲突,Git会自动将冲突的文件标记出来。我们需要手动解决冲突,然后再次提交修改。