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

相关推荐
权咚7 小时前
阿权的开发经验小集
git·ios·xcode
nightunderblackcat1 天前
新手向:Git下载全攻略
git
若无_1 天前
了解 .husky:前端项目中的 Git Hooks 工具
前端·git
想当花匠的小码农1 天前
Git 仓库“减肥”指南:从检测、清理到同步的全流程实践
git
R_.L2 天前
Git : 基本操作
git
python_1362 天前
git常见冲突场景及解决办法
git
洛小豆2 天前
Git 打标签完全指南:从本地创建到远端推送
前端·git·github
王道长服务器 | 亚马逊云2 天前
一个迁移案例:从传统 IDC 到 AWS 的真实对比
java·spring boot·git·云计算·github·dubbo·aws
嘟嘟可在哪里。2 天前
IntelliJ IDEA git凭据帮助程序
java·git·intellij-idea