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

相关推荐
爱喝矿泉水的猛男1 小时前
Git Commit 提交信息标准格式
git·commit
℘团子এ1 小时前
git中,将新项目推送到新建的远程仓库
git
gitboyzcf1 小时前
Git 常用命令
前端·git·后端
哈里谢顿2 小时前
Git 最实用的四个还原命令详解
git
xiAo_Ju17 小时前
git hooks配置
git
mit6.82419 小时前
[Git] 如何拉取 GitHub 仓库的特定子目录
git·github
许心月20 小时前
Git#revert
git
军军3601 天前
Git大型仓库的局部开发:分步克隆 + 指定目录拉取
前端·git
间彧1 天前
Git命令速查表
git
用户2519162427111 天前
Git原理分析
前端·javascript·git