Git的使用

安装

查看是否安装 git

1
git version
这是图片

配置

配置用户

  • 当前项目的用户
1
git config user.name "你的用户名"
1
git config user.email "你的邮箱"
  • 全局用户
1
git config --global user.name "你的用户名"
1
git config --global user.email "你的邮箱"

查看 git 用户配置

  1. 查看系统 config
1
git config --system --list
  1. 查看当前用户(global)配置
1
git config --global --list
这是图片
  1. 查看当前仓库配置信息
1
git config --local --list
这是图片

使用

上传到代码仓库管理平台

  • 创建 git 仓库
1
git init
  • 关联本地项目到远程仓库
1
2
# origin 为链接远程仓库的别名,可以改成别的
git remote add origin 远程地址
  1. 存到暂缓区
1
git add .
  1. 提交内容
1
git commit -m "提交内容"
  1. 提交到远程仓库
1
git push 链接远程仓库的别名 仓库分支

更新最新代码

  • 拉取最新代码
1
git pull
  • 拉取某个分⽀最新代码
1
git pull 链接远程仓库的别名 分支名

查看当前分支状态

1
git status

查看提交文件

1
git log

更改 commit

  • 未进行 push 的 commit
1
git commit --amend

提交规范

1
2
3
4
5
6
7
8
9
10
11
12
feat: 新功能(feature)
fix: 修补bug
docs: 文档(documentation)
style: 格式(不影响代码运行的变动)
refactor: 重构(即不是新增功能,也不是修改bug的代码变动)
chore: 构建过程或辅助工具的变动
revert: 撤销,版本回退
perf: 性能优化
test:测试
improvement: 改进
build: 打包
ci: 持续集成

git-emoji-guide

git 打 tag

用 git 给项目打 tag 标签


Git的使用
https://www.gongyibai.site/git的使用/
作者
爱吃糖醋排骨的苏小妍.
发布于
2024-11-26 17:04:16
更新于
2024-12-16 16:00:29
许可协议