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

相关推荐
你的人类朋友16 分钟前
hotfix分支的使用
git·gitlab·github
小蜜蜂爱编程1 小时前
gerrit的部署与配置关联到不同服务器上的git仓库
运维·服务器·git·gerrit
颇有几分姿色3 小时前
Git将本地项目推送到GitLab
git·gitlab
Kent_J_Truman7 小时前
Git个人配置偏好记录以及注意事项
git
小龙报9 小时前
《算法每日一题(1)--- 连续因子》
c语言·开发语言·c++·windows·git·算法·visual studio
今禾11 小时前
Git完全指南(中篇):GitHub团队协作实战
前端·git·github
flow_code1 天前
切换git账户
git
春生野草1 天前
Gituee
git·gitee
222you1 天前
Git推送本地仓库到远程
git
小贾要学习1 天前
如何在Linux操作系统环境下使用git命令提交文件到远程仓库
linux·运维·git