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

相关推荐
头发那是一根不剩了8 小时前
Git 常用命令
git
x-cmd9 小时前
[x-cmd] x git - Git 命令增强工具
git·终端·命令行·x-cmd
程序员果子10 小时前
Git从零到远程协作:手把手实战指南
git
猫头虎14 小时前
OpenClaw 常用操作命令完整速查手册:终端 CLI 操作指令详解|聊天斜杠指令详情
运维·git·容器·开源·github·aigc·ai编程
小哈里1 天前
【工具】Linux远程开发核心工具,Git命令缩写与SSH常用命令
linux·git·ssh·工具·远程开发
迈克桀森1 天前
Git 日常操作全攻略:拉取 / 提交代码 + 高频命令速查
git·github
CCC:CarCrazeCurator1 天前
详解文件与文件夹权限:谁能操作、能做什么
git
Delta-delta2 天前
Git:warning: Clone succeeded, but checkout failed.
git
日光倾2 天前
【Vue.js 入门笔记】Git入门
笔记·git
dreams_dream2 天前
Git 的 Tag
git