zoukankan      html  css  js  c++  java
  • git使用

    基础

    工作区: 当前的编辑位置

    缓存区: add 之后的区域

    版本库:commit之后的区域就是版本库

    git init . 初始化

    git add . 将工作区的所有文件添加到缓存区

    git commit -m “提交信息” 将缓存区的内容添加到版本库

    git status 查看当前的状态

    git reset --hard hash值 回退到指定的版本

    git checkout -- file 将文件回滚到最近一次提交的样子

    git log 查看当前位置之前的提交记录

    git reflog 查看所有的记录

    git reset HEAD file 将缓存区的文件拉取到工作区

    git diff 对比工作区和缓存区

    git diff --cached 对比版本库和缓存区

    快照

    git  stash 将当前的内容做快照,并回到最后一次提交的位置

    git stash list  查看快照

    git stash pop 回到快照的位置,并删除这个快照

    git stash drop 删除快照

    git stash apply 回到快照

    分支

    git branch 查看分支列表

    git branch name 创建分支

    git checkout name 切换分支

    git checkout -b name 创建分支并切换分支

    git branch -d name 删除分支

    git merge name 在合并到的分支上进行合并

    冲突

    Auto-merging templates/index.html
    CONFLICT (content): Merge conflict in templates/index.html
    The stash entry is kept in case you need it again.

    手动解决

    远程仓库

    git clone 默认master分支

    git checkout -b dev origin/dev  取出分支

    git push origin  dev 将本地分支推送到远程仓库

    git pull   拉取代码

    git remote add origin https://url.git 创建别名

    给别人贡献代码

    先 fork 

    在本地修改

    new  pull  request    等待对方是否采取

    标签(版本信息

    git tag 

    git tag -a v1.0 -m “信息”

    git tag -d 删除

    git push origin --tag

    git push origin :refs/tags/v1.0

    忽略文件

    .gitignore

    gitlab 公司私有 (一般都是这种公司搭建的)

  • 相关阅读:
    别闹了,这些都不是数字化转型
    对不起,“下一代ERP”仍旧是现在的ERP
    这世界真小
    SAP S4HANA 2020 Fully-Activated Appliance 虚拟机版分享
    花费巨资参加SAP培训真的有用吗?
    剑指 Offer 07. 重建二叉树
    剑指 Offer 06. 从尾到头打印链表
    剑指 Offer 05. 替换空格
    剑指 Offer 04.二维数组中的查找
    剑指 Offer 03. 数组中重复的数字
  • 原文地址:https://www.cnblogs.com/Wj-Li/p/10864897.html
Copyright © 2011-2022 走看看