git基本使用命令

26 阅读1分钟
0.git安装包

①下载地址:git-scm.com/downloads/
②用户配置:
在这里插入图片描述

1.常用git命令
git status          //查看当前项目文件夹中的文件状态
git status -s       //简化查看文件状态列表
git add index.html     //将指定的单个文件(index.html)提交到本地仓库的暂存区
git add .          //将所有文件提交到仓库的暂存区
git commit -m"本次提交的版本的备注信息"
git checkout -- index.html    //将仓库中的文件(index.html) 覆盖工作区中的同名文件(index.html)
git reset head index.html   //将暂存区中的文件(index.html)移除
git commit -a -m    //跳过暂存区直接提交到仓库区(注意:新创建的文件不能,只有托管的文件才能这样提交)


git remote add origin address  //在本地保存远程仓库的地址,并取别名为origin
git remote   //查看本地仓库保存的地址别名
git remote get-url origin    //根据别名查看具体的地址
git push -u origin master    //将本地仓库当前版本 提交到别名为origin的远程仓库的maser分支


git branch   //查看分支  (*代表当前所在分支)
git branch login(分支名)  //创建新分支(即复制当前所在分支)   
git checkout login   //切换分支
//注意:切换分支会切换工作区
git checkout -b login   //创建并切换分支
git merge 目标分支   //目标分支合并到当前分支
git branch -d login   //删除分支
git push -u origin login //推送分支

git clone  address  //克隆文件夹,默认克隆主分支
git clone -b 分支名 address //克隆指定分支的文件

vim .gitignore  //添加忽略文件
2.git终端操作界面

2.1本地托管
在这里插入图片描述
2.2 与托管平台建立连接 上传到托管平台
在这里插入图片描述

4.gitlab上拉取指定分支

在这里插入图片描述