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

相关推荐
真上帝的左手2 小时前
3. 代码管理-Git-进阶
git·源代码管理
YIN_尹6 小时前
【git原理与使用】git基本操作及底层原理(二)
大数据·git·elasticsearch
程序员爱德华12 小时前
Git 命令
git
Cry丶1 天前
Git Rebase 操作备忘
git·rebase
你叶不叶1 天前
abap git 如何从 gitee上在线拉取数据(上一步已经配置好证书)
git·gitee·sap·abapgit
kuroomi2 天前
Git入门
git·kubernetes
daliucheng2 天前
lazygit 上手:日常 git 操作一篇讲完
git
codigger2 天前
大厂git提交规范
git·程序员
挖掘狂人2 天前
六条分支,一条主干:我的 Git 分支管理心得
git·后端·程序员
Brookty3 天前
Git与GitHub系统学习|本地Git工作模型:终端与进程、CWD、HEAD/Index/工作树及Git对象
git·github