Git 相关操作

1,配置用户名和邮箱

复制代码
git config --global user.name "My Name"

git config --global user.email "myemail@example.com"

2,查看git设置,包含查看用户名和邮箱

复制代码
git config --list

3, 查看修改了哪些文件

复制代码
git status

4, 更新将要提交的内容

复制代码
git add <file>

5,提交更改

复制代码
git commit
# -m 与commit命令一起,指定提交信息
eg: git commit -m "version 1"

# -a commit 之前可以自动暂存每个更改的文件,此flag可以省去 git add

6, 创建branch

复制代码
git branch <branch-name> 
or:
git checkout -b <branch-name> 

#both create a branch but checkout switch to the new branch

7,推送到远端仓库

复制代码
git push -u origin HEAD

# Using HEAD is a "handy way to push the current branch to the same name on the remote". 
# In Git terms, HEAD (in uppercase) is a reference to the top of the current branch (tree).
# The -u option is just short for --set-upstream. This will add an upstream tracking reference for the current branch

参考:

Git - Recording Changes to the Repository

https://stackoverflow.com/questions/2765421/how-do-i-push-a-new-local-branch-to-a-remote-git-repository-and-track-it-too

相关推荐
墨白曦煜19 小时前
穿透 IDE 的障眼法:Git 四大工作区与核心数据流转解析
ide·git
idealzouhu20 小时前
深入 Git 账户模型:从提交身份到 SSH 多账户隔离的完整实践
git·ssh
是2的10次方啊20 小时前
误推 master 该 revert 还是 reset?撤销与补 MR 流程
git
菠萝加点糖1 天前
Git 删除远程文件、本地保留并取消跟踪
git
理智.6292 天前
Git 工具使用之项目版本回退与修改备份:stash、reset、reflog 常用指令详解
git·gitee·github
妙码生花2 天前
GIT 提交规范
git
云雀衔光2 天前
多个 MCP Server 怎么编排:数据库 / Redis / Git / 飞书一把梭
java·数据库·人工智能·redis·git·语言模型·飞书
Java后端的Ai之路2 天前
Git pull弹出vim编辑器完整排查指南
开发语言·人工智能·git·编辑器·vim
云泽8082 天前
Git 版本控制系统(下):从 .git 目录结构到冲突解决机制详解
大数据·git·elasticsearch
麻辣布丁3 天前
Git冲突原因与解决方法全解
大数据·git·elasticsearch