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

相关推荐
難釋懷13 小时前
Redis网络模型-单线程和多线程网络模型变更
网络·redis·git
不做无法实现的梦~14 小时前
Git 新手到团队协作与 GitHub/GitCode 指南
git·github·gitcode
谷哥的小弟14 小时前
(最新版)Git&GitHub实操图文详解教程(02)—安装Git
git·github·安装·配置·下载·图文教程
高斯林.神犇14 小时前
Git远程仓库操作流程
git
谷哥的小弟14 小时前
(最新版)Git&GitHub实操图文详解教程(01)—Git的起源
git·github
小此方15 小时前
Re:Linux系统篇(十四)工具篇 · 五:Git 高效协作实战与“三板斧”秘籍
linux·git·github
拾-光1 天前
【Git】命令大全:从入门到高手,100 个最常用命令速查(2026 版)
java·大数据·人工智能·git·python·elasticsearch·设计模式
Snooker_1461 天前
TRAE、VSCode上进行git管理
ide·git·vscode
zincsweet1 天前
Git开发工具教程
git
yuyuyui1 天前
Git实战覆盖98%日常开发场景
git