更新提交相关
- git clone url //克隆指定url地址的代码支本地空间
- git add test1.txt test2.txt //添加test1和test2两个文件
- git add . //添加当前版本下的 所有修改
- git commit -m ''message" //提交; “message”指注释
- git push //将修改推至远程仓库
- git fetch //从远程仓库拉取最新的版本至本地仓库
- git fetch origin xxx //拉取指定分支到指定仓库
- git merge //合并本地仓库的代码至工作区
- git pull // 从远程仓库拉取至本地仓库并merge ,相当于 git fetch + git merge
- git status //查看本地仓库当前状态
git pull (拉代码)、git push(推代码)最常用
vscode前端提交代码:add --》commit --》push
分支管理相关:
- git checkout -b develop origin/develop //检出远程的develop分支至本地
- git checkout develop //切换至develop分支(develop分支已存在)
- git branch test //本地新建test分支
- git push orign test //将本地新建分支test推至远程
- git branch -a //查看所有分支
- git branch -r //查看远程分支
- git branch -w //查看本地分支与远程分支的关联关系
- git push -d origin test // 删除远程test分支
- git branch -d test //删除本地test分支
撤回修改相关:
- git checkout --test1.txt //未add之前撤回修改/抛弃掉test1的修改
- git reset HEAD test1.txt //add之后commit之前的撤回test1.txt的修改
- git reset --hard HEAD^ //commit之后回退至git log 中的上一个版本
- git reset --head<commit-id> //commit之后回退至git log 中指定commit-id 的版本