git初始化
- git --version:查看安装的git版本
要在 Git 中设定个人资料,需要运行以下命令:
-
git config --global user.name “[name]”:设置 Git 用户名为 name,例如:
git config --global user.name "John Doe"
-
git config --global user.email “[email address]”:设置 Git 用户邮箱为邮箱地址,例如:
git config --global user.email "johndoe@example.com"
可以使用 --global
标志来告诉 Git 在全局范围内应用这些配置,这样在所有项目中都可以使用这些资料。如果想在特定项目中设定,可以去掉 --global
标志,或在项目中使用这些命令进行配置。
设定完成后,可以运行 git config --list
来查看当前 Git 配置。
git基本原理
-
进入某个文件夹(工作目录)—— cd [文件夹地址]
-
git init:初始化一个本地仓库(即在该文件夹下创建了一个本地仓库)
如果对文件夹中的文件有更新,比如新建了一个index.html,此时执行git status:可以显示本地仓库状态