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

相关推荐
玄芯散人11 小时前
【筑基·058】Git协作工作流:冲突解决和PR流程
git·版本控制·团队协作
寺中人14 小时前
Git 版本控制完全入门指南:从安装到实战,提交 + 分支 + 协作 + 冲突解决全拆解
git·开发工具·版本控制·团队协作·代码管理
荔枝梅梅16 小时前
新手程序员 SSH 第一课:从 Git 仓库连接失败理解 SSH 协议与密钥配置
git
玄芯散人16 小时前
【筑基·057】Git代码时光机:版本控制入门到分支管理
git·版本控制·嵌入式开发
szephyr19 小时前
Git 分支管理实战:feature/release/hotfix 怎么用才不乱
git·分支管理·团队协作·工作流·hotfix
一木 之林19 小时前
手搓家庭服务器:二手装机、Docker部署、端口映射与frp内网穿透
服务器·人工智能·git·编辑器
烛之武19 小时前
Git教程笔记
git·gitee
Sharewinfo_BJ20 小时前
PBIP项目结构与文件解析
git·powerbi·智信bi·上北智信
Hvitur1 天前
Linux安装Git【离线安装】
git
howard20052 天前
6.4 Git安装与配置
git·安装配置