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

相关推荐
星海拾遗6 小时前
git rebase记录
大数据·git·elasticsearch
ljh5746491197 小时前
PhpStorm 2022.3 版本中,修改使用 Git 提交时看到弹出式的对话框模式
ide·git·php·phpstorm
云闲不收9 小时前
git rebase
git
江上清风山间明月9 小时前
git pull和git checkout在恢复文件的区别
git·pull·checkout
海鸥8110 小时前
in argocd ‘/tmp/_argocd-repo/../.git/index.lock‘: No space left on
git·argocd
尔嵘12 小时前
git操作
大数据·git·elasticsearch
好评12412 小时前
Linux文件上传git
linux·运维·git
大柏怎么被偷了14 小时前
【Git】企业级开发模型
git
Garfield200514 小时前
Git 分支拓扑实践
git·拓扑
DKNG14 小时前
【Windows Host】 hosts配置增加访问github流畅度
人工智能·git·github