git 常规使用

git 报错设置

全局设置

1
2
3
4
5
6
7
8
#引号部分,需要输入你注册Github的邮箱
git config --global user.email "you@example.com"
# 引号部分输入你的Github账户用户名
git config --global user.name "Mysuy"
#邮箱
git config --global user.email "15075264+mysuy@user.noreply.gitee.com"
输入完成后,再次执行命令Commit:
git commit -m "Add test file"

git 使用

1. git clone

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
git clone <仓库地址>
# 示例:
git clone https://github.com/user/project.git
# 克隆默认的远程仓库的默认分支"main"/"master"

git branch # 查看分支

git log # 项目的开发记录
# --oneline # oneline是一行显示

git checkout -b newbranch # 创建并切换到新分支
git checkout main # 切换到主分支
git merge newbranch # 合并分支
git branch -d newbranch # 删除分支

git status # 查看当前状态
# modfiles 修改的文件 Untracked files 新增的文件

git add . # 添加所有修改的文件到暂存区

git commit -m "提交信息" # 提交到本地仓库
git push -u origin newbranch # 推送到远程仓库

git pull # 拉取远程仓库的代码