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

相关推荐
minji...29 分钟前
linux 进程控制(一) (fork进程创建,exit进程终止)
linux·运维·服务器·c++·git·算法
系夏普31 分钟前
Git 入门教程:初始化、修改与提交
git
laplaya1 小时前
Git 使用技巧
git
奶油松果1 小时前
git amend记录
git
庸俗今天不摸鱼2 小时前
git提交代码失败?本地代码被清空了?git代码丢了怎么办?三步帮你找回来
git
摇滚侠2 小时前
零基础小白自学 Git_Github 教程,Git 命令行操作3,笔记20
笔记·git·github
摇滚侠3 小时前
零基础小白自学 Git_Github 教程,GitLFS ,笔记21
笔记·git·github
lpfasd1233 小时前
Git之外的新选择?PlasticSCM深度对比与平台支持全解析
git
Cx330❀3 小时前
Git 入门指南:从 0 到 1 掌握版本控制
git·ubuntu·gitee·centos·github
爱凤的小光4 小时前
Git自我学习笔记
笔记·git·学习