后续遇到还会更新常用指令~
3.首次安装git
因为初次提交项目到远程仓库时、
会提示please run
git config --global user.name "取个昵称"
git config --global user.email "用户邮箱"
所以设置完后就按照流程
git add .
git commit -m "说明内容"
git pull
git push
2.实际工作中常用到
克隆远程仓库的指定分支
git clone -b 远程分支名 远程仓库地址
克隆的项目经过自己写入一些内容后、准备提交回去
git add .
git commit -m "说明"
git pull
git push
如果在git pull时出现了“一大片空白”、(在英文状态下) 按shift + ;
然后输入wq 敲回车 最后再执行git push
1.常用的命令案例
Git 本地分支与远程分支关联
git branch --set-upstream-to=origin/remote_branch your_branch
其中,origin/remote_branch是你本地分支对应的远程分支;your_branch是你当前的本地分支
克隆远程仓库的指定分支
git clone -b 远程仓库分支的名称 远程仓库的地址
$ git clone -b 远程分支名 https://gitee.com/xxxxxx/hhhh.git
将本地的项目推送到git仓库指定的分支
git push 仓库地址 本地分支名:远程分支名
$ git push https://gitee.com/xxxxxx/hhhh.git 本地分支名:远程分支名
git pull仓库地址 远程分支名:本地分支名
$ git pull https://gitee.com/xxxxxx/hhhh.git 远程分支名:本地分支名
不建议使用git pull仓库地址 远程分支名:本地分支名(因为这个,导致我被项目经理“严谨”了,所以不建议这样搞)
因为项目通过clone下来的,所以拉同一个项目的时候直接使用git pull就好
查看本地所有分支
git branch
本地仓库切换分支
git checkout 分支名
$ git checkout dd
创建本地分支
git branch 本地分支名
$ git branch dd
删除本地分支
git branch -D 本地分支名
$ git branch -D dd
Deleted branch dd (was c80c38a).