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

相关推荐
深海鱼在掘金5 天前
Git 完全指南 —— 第1章:Git 概览与版本控制演进
git
noravinsc6 天前
关于Git Flow
git
蜜獾云6 天前
在Git中配置用户名和密码
git
scx_link6 天前
通过git bash在本地创建分支,并推送到远程仓库中
开发语言·git·bash
南大白6 天前
IntelliJ IDEA 运行时的 JVM 本地内存溢出崩溃
git
码农小旋风6 天前
Claude Code 基础用法大全:对话、分析、修改、测试、Git 和工作流
人工智能·git·chatgpt·claude
南大白6 天前
Git 撤回提交完整方案
git
像风一样的男人@6 天前
python --实现代理服务器
git·ui
sbjdhjd6 天前
从零搭建企业级 CI/CD(下):Jenkins+GitLab+Harbor 全链路实战指南
git·servlet·ci/cd·云原生·云计算·gitlab·jenkins
码云数智-大飞6 天前
Go Channel 详解:并发通信的正确姿势
前端·数据库·git