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 
相关推荐
apcipot_rain1 小时前
【应用密码学】实验五 公钥密码2——ECC
前端·数据库·python
ShallowLin1 小时前
vue3学习——组合式 API:生命周期钩子
前端·javascript·vue.js
Nejosi_念旧2 小时前
Vue API 、element-plus自动导入插件
前端·javascript·vue.js
互联网搬砖老肖2 小时前
Web 架构之攻击应急方案
前端·架构
pixle02 小时前
Vue3 Echarts 3D饼图(3D环形图)实现讲解附带源码
前端·3d·echarts
麻芝汤圆3 小时前
MapReduce 入门实战:WordCount 程序
大数据·前端·javascript·ajax·spark·mapreduce
juruiyuan1115 小时前
FFmpeg3.4 libavcodec协议框架增加新的decode协议
前端
Peter 谭5 小时前
React Hooks 实现原理深度解析:从基础到源码级理解
前端·javascript·react.js·前端框架·ecmascript
LuckyLay6 小时前
React百日学习计划——Deepseek版
前端·学习·react.js
gxn_mmf6 小时前
典籍知识问答重新生成和消息修改Bug修改
前端·bug