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 小时前
如何在新机器上设置github完成内容git push
git·github
小妖6666 小时前
git branch -a 还有一些已经删除了的分支
git
&Sinnt&1 天前
Git 版本控制完全指南:从入门到精通
git·后端
Tiny2141 天前
多人协同开发时Git使用命令
git
WebGirl1 天前
代码Revert后再次Merge会丢失的问题
git
小皮侠1 天前
nginx的使用
java·运维·服务器·前端·git·nginx·github
HalukiSan1 天前
如何提交PR
git·gitlab·github
爱莉希雅&&&2 天前
shell编程之awk命令详解
linux·服务器·git
baiyu332 天前
成为git砖家(12): 看懂git合并分支时冲突提示符
git
wu_aceo2 天前
将本地项目提交到Gitee
git·gitee·提交·本地提交·上传git