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

相关推荐
yanlaifan3 小时前
git版本管理工具中的回车换行转换逻辑
git
小僧景贤16 小时前
【零门槛入门】嵌入式新手极简 Git 上手教程
git·固件开发·嵌入式版本管理
克里斯蒂亚诺更新16 小时前
云效和IDEA关于git的相通使用
git
Gavynlee17 小时前
Git 操作问题排查与解决方案记录(Gitee 实战)
git·elasticsearch·gitee
邪修king17 小时前
Re:Linux系统篇(十):从零上手 Git + GitHub(Ubuntu 环境实操完整版|个人代码归档必备)
linux·git·github
李可以量化17 小时前
Redis 从了解到精通(三)下:性能基准测试与量化场景性能避坑指南
redis·git·python·量化交易·qmt·ptrade
青 春 记 忆1 天前
零基础入门Python11|Git实战:为任务管理器建立版本历史
开发语言·git·vscode·python·python3.11
牢姐与蒯1 天前
Linux基础开发工具之版本控制器git
git
云原生指北1 天前
Docker Sandboxes 工作区怎么接:Direct、Clone 和它们的边界
git·docker·agent
菠萝猫yena1 天前
【git】git 命令常用组合
大数据·git·elasticsearch