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

相关推荐
yeziyfx2 小时前
vs code 使用Git拉取/克隆(clone)仓库项目
git·vscode
smachao10 小时前
Redis Desktop Manager(Redis可视化工具)安装及使用详细教程
redis·git·bootstrap
szcsun511 小时前
git的常用命令
git
jian1105812 小时前
android studio 解决git用户名和用户邮箱不一致的问题
git
jian1105812 小时前
Mac git配置账号和邮箱,可以修改
git·macos
笨笨饿14 小时前
博客目录框架
c语言·开发语言·arm开发·git·嵌入式硬件·神经网络·编辑器
白玉cfc15 小时前
git协作开发
git·团队开发·远程工作
Rabbit_QL16 小时前
【CI/CD】02_一次 git push 后发生了什么?CI 是怎么工作的
git·ci/cd
不会写DN16 小时前
Git 开发中最常用的命令与场景
大数据·git·elasticsearch
张二娃同学17 小时前
基于 Python 与 Tkinter 的猜数字游戏设计与实现:支持玩家猜数与 AI 反向推理
开发语言·git·python·游戏·开源