git基础命令

git流程

使用步骤:

javascript 复制代码
1.初始化本地仓库
git init

git config --global  --list 查看
2.添加远程库,down下项目到本地库文件夹
git remote add origin git+仓库地址
// 此时的origin,对应第一步的远程分支名,可以在添加连接的同时,设置远程分支名


git remote add origin [email protected]:2226/apm/common/license/licence-v2/frontend.git

git remote add origin [email protected]:HTML-CSS-learning/global_template.git

3.查看当前本地仓库分支
git branch

4.本地无分支,则新建分支
git branch 分支名 

5.创建本地分支后,切到所创本地仓库分支
git checkout 想要切换到的分支名

6.查看远程分支
git branch -r

7.查看修改状态
git status

8. 添加至暂存区
git add .

9. git commit -m "添加你的注释,一般是一些更改信息"


新建远程分支,并将本地分支push到远程分支

10.push到远程分支,远程自动创建一个远程分支
git push -u origin master // 第一次提交,需要加-u,后面就不需要了
git push origin 远程分支名


10.查看commit的记录
git log --oneline

11.根据commit的id,回到之前的提交
git reset 要撤回提交的前一次的commit的id,必须是前一次是id

12.清空暂存区
git rm -r -f --cached .

核心:

js 复制代码
git status
git add.
// 查看当前连接的仓库
git remote -v
git commit -m "添加你的注释,一般是一些更改信息"
git push origin 远程分支名

git log --oneline
git reset commit提交对应的id

git update-ref -d HEAD 撤销第一次提交

功能模块常用推送

shell 复制代码
git status 
git add .
git commit -am "分类模块"
git push origin v1.0
git tag tag-dev-category 
git tag tag-dev-1.0
git push origin tag-dev-category 

初始化

shell 复制代码
git branch

tag标签

  • 打tag标签

    shell 复制代码
    git tag tag名(例如tag-dev-initial)
  • push tag标签

    shell 复制代码
    git push origin 标签名

仓库

连接仓库

shell 复制代码
git remote add origin git+仓库地址

组织仓库:
git remote add origin [email protected]:hsmall/admin-fe.git

拉取仓库项目

shell 复制代码
git pull+仓库地址

组织仓库
git pull [email protected]:HTML-CSS-learning/static_barley_net.git

推送到仓库

shell 复制代码
git push

分支

查看本地分支

shell 复制代码
git branch

切换分支

shell 复制代码
git checkout 分支名

查看远程分支

shell 复制代码
git branch -r

创建本地分支

shell 复制代码
git branch 分支名 ----注意新分支创建后不会自动切换为当前分支
git checkout -b v1.0 ----创建并切换到该分支

/** 推送 */
git push
git push -set -upstream origin mall v1.0

创建远程分支(本地分支push到远程)

shell 复制代码
git push origin 远程分支名

删除本地分支

强制删除一个分支

shell 复制代码
git branch -D 分支名

git branch -D huangsheng_dev

只删除已经参与了合并的分支

shell 复制代码
git branch -d 分支名

删除远程分支

shell 复制代码
git push origin --delete 分支名

很多在远程仓库已经删除的分支在本地依然可以看到,删除那些远程仓库不存在的分支

删除依然存在的远程分支

shell 复制代码
git remote prune origin

推送到远程分支

shell 复制代码
 git push origin huangsheng_dev
 git push origin v1.0

提交本地huangsheng_dev分支作为远程的huangsheng_dev分支

远程同时也自动创建

复制代码
git push origin huangsheng-dev:huangsheng_dev 
相关推荐
尘寰ya几秒前
什么是原型污染?如何防止原型污染?
前端·面试·原型模式
鸿蒙场景化示例代码技术工程师4 分钟前
实现实时语音转文字功能鸿蒙示例代码
前端
ohMyGod_1239 分钟前
高阶函数/柯里化/纯函数
前端·react.js·前端框架
CsharpDev-奶豆哥13 分钟前
如何理解前端开发中的“换皮“
前端·css·css3
Mike_jia14 分钟前
Navicat 数据库管理全攻略:从基础操作到企业级应用实战
前端
Jackson_Mseven14 分钟前
如何从0到1搭建基于antd的monorepo库——使用rollup进行打包、lerna进行版本管理和发布(六)
前端·react.js·ant design
圆号手15 分钟前
手搓ag-grid带筛选的下拉选择器(类似企业版的agRichSelectCellEditor)
前端
Lestat16 分钟前
Vue Router 中 params 和 query 的区别
前端
静思己过17 分钟前
AutoDecimal:轻松解决 JavaScript 运算精度问题之toDecimal
前端·javascript
任子行17 分钟前
前端html、css基础的基础
前端