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

相关推荐
2401_8260976218 小时前
同步&异步日志系统-日志落地模块的实现
c++·git·vim
半旧夜夏19 小时前
阿里云IOT消息处理
java·ide·git·物联网·spring·阿里云
我们的五年20 小时前
【Git版本控制器】第三弹——版本回退,撤销修改,删除文件
大数据·linux·git
一名嵌入式糕手20 小时前
Git从基础到进阶
git
不cong明的亚子21 小时前
github用户名密码登陆失效了
git·github
QC七哥21 小时前
git开发流程以及github社区企业版
git·github
邂逅you1 天前
GitHub基本操作及Git简单命令
git·github
EngZegNgi1 天前
git 提示 fatal: The remote end hung up unexpectedly
git
ricky_fan1 天前
本地部署MindSearch(开源 AI 搜索引擎框架),然后上传到 hugging face的Spaces——L2G6
人工智能·git·python
misty youth1 天前
github与git bash绑定问题
git·github·bash