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

相关推荐
Demons_kirit9 小时前
CTFHub 信息泄露通关笔记:Git泄露 Log - 教程
笔记·git·网络安全
鬼手点金16 小时前
构建有效 Agent 的核心原则
java·人工智能·git·学习·自动化
索西引擎17 小时前
Git 大文件阻断推送的成因与历史重写修复
git
csdn2015_18 小时前
git 合并分支
大数据·git·elasticsearch
91440623218 小时前
mac Git 账户切换问题
git·macos
留岁19 小时前
Git 命令行学习记录
git·学习·elasticsearch
笨笨饿19 小时前
#142_VS Code.map文件插件的用法
git·python·stm32·单片机·嵌入式硬件·物联网·vim
鬼手点金21 小时前
如何选择模型
java·前端·人工智能·git·深度学习
余槐i21 小时前
Claude Code Skills 放对目录却不生效:插件启用顺序与缓存的三个坑
git·开发工具·ai agent·mcp·claude code
程序员差不多先生2 天前
Anthropic 用 5 个月重写了 Git:当 AI Agent 把版本控制系统逼到墙角
人工智能·git·elasticsearch·deepseek v4 pro·kimi k3·glm 5.3·qwen3.7 max