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

相关推荐
C++ 老炮儿的技术栈2 小时前
在C++ 程序中调用被 C编译器编译后的函数,为什么要加 extern “C”声明?
c语言·c++·windows·git·vscode·visual studio
Robin罗兵5 小时前
git使用教程2
git
bob_young8 小时前
Git LFS + Gerrit 配置+lfs-test-server(git lfs push总是提示输入https密码解决)
git·lfs
半夏微凉半夏殇10 小时前
git add . 是否会包含.o、.so、.ko文件?深度解析与避坑指南
git
牟同學11 小时前
Git 实战场景操作大全(可直接落地)
git
不做无法实现的梦~11 小时前
使用ros2跑mid360的fastlio2建图
git·单片机·嵌入式硬件·gitcode
长沙红胖子Qt14 小时前
SVN培训笔记(二):使用sourceTree通过git桥接管理svn项目
git·svn·sourcetree·sourcetree管理svn
半夏微凉半夏殇15 小时前
从多仓库到单仓库:如何高效迁移并统一管理多个Git项目
git
__万波__15 小时前
解决警告“..LF will be replaced by CRLF the next time Git touches it“
git
Software攻城狮16 小时前
git报错处理
git