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

相关推荐
YoseZang7 小时前
【手工】git的使用 – 使用git进行项目协作
git
惺忪97988 小时前
git 多个branch对多个版本进行管理
git
夜瞬11 小时前
Git工作流程与常用指令——从本地开发到远程协作
大数据·git·elasticsearch
FEF前端团队11 小时前
开发知识库 #01:Git 全面操作教程
git·github
weixin_5316518115 小时前
Git 操作指南
大数据·git·elasticsearch
一个程序猿老马18 小时前
003、Git核心概念:仓库、工作区、暂存区、版本库
大数据·git·elasticsearch
披着羊皮不是狼18 小时前
Git完整学习总结
git·学习·elasticsearch
DevilSeagull18 小时前
MySQL(1) 安装与配置
java·数据库·git·mysql·http·开源·github
一个程序猿老马18 小时前
005、Git三板斧(1):git add - 将文件纳入版本管理
大数据·git·elasticsearch
Cyber4K19 小时前
【DevOps专项】Git 部署及使用方法
运维·git·devops