目录

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

本文是转载文章,点击查看原文
如有侵权,请联系 xyy@jishuzhan.net 删除
相关推荐
FixBug_Nick15 小时前
Jenkins配置的JDK,Maven和Git
java·git·jdk·jenkins·maven
weixin_4612594118 小时前
git命令自动拉去远程分支到本地
git
程序猿chen19 小时前
JVM考古现场(十七):鸿蒙初辟——从太极二进到混沌原初的编译天道
开发语言·jvm·git·后端·程序人生·java-ee·改行学it
早已忘记21 小时前
git命令
大数据·git·elasticsearch
愚润求学1 天前
【Linux】Git的简单使用
linux·服务器·git
HahaMonsters1 天前
Git 中回退版本后修改并提交
git
大小科圣1 天前
git版本控制器
git
ZZQ-ZZQ1 天前
版本控制工具——Git
git·gitee·github·版本控制·gitea
前端啊龙2 天前
Git vs SVN 核心区别
git·svn
CyberSecurity_zhang2 天前
Git工作流、命令汇总
服务器·git