设置用户信息
git config --global user.name “itcast”
git config --global user.email “hello@itcast.cn”
查看配置信息
git config --list
获取Git 仓库-在本地初始化Git仓库
执行步骤如下:
1. 在任意目录下创建一个空目录(例如repo1)作为我们的本地Git仓库
2. 进入这个目录中,点击右键打开Git bash窗口
3. 执行命令git init
获取Git 仓库-从远程仓库克隆
git clone 【远程Git仓库地址】
本地仓库操作
本地仓库常用命令如下:
git status查看文件状态
git add将文件的修改加入暂存区
git reset将暂存区的文件取消暂存或者是切换到指定版本
git commit -m ""将暂存区的文件修改提交到版本库
git log 查看日志
远程仓库操作
前面执行的命令操作都是针对的本地仓库,本节我们会学习关于远程仓库的一些操作,具体包括:
git remote 查看远程仓库
git remote add添加远程仓库
git clone从远程仓库克隆
git pull从远程仓库拉取
git push[橙子][分支]推送到远程仓库
分支操作
本节我们会学习关于分支的相关命令,具体如下:
git branch查看分支
git branch [name]创建分支
git checkout [name]切换分支
git push [shortName] [name]推送至远程仓库分支
git merge [name]合并分支
分支操作- 查看分支
git branch列出所有本地分支
git branch -r列出所有远程分支
git branch -a列出所有本地分支和远程分支
标签操作
git tag列出已有的标签
git tag [name]创建标签
git push [shortName] [name]将标签推送至远程仓库
git checkout -b [branch] [name]检出标签