zoukankan      html  css  js  c++  java
  • git常用命令

    git init——新建本地仓库
    git add <file/dir>——将文件添加到暂存区,git add .添加当前文件夹所有内容
    git status——查看当前文件跟踪状态
    git commit -m "<版本说明>" ——提交暂存区中的文件到本地仓库;git commit -a -m "<版本说明>"——直接提交工作区所有最新改动过的文件,在这之前不需要add文件到暂存区

    git log——查看历史版本,--graph --decorate --oneline --all用点线图查看历史版本
    git branch——查看已创建的分支,git branch <new branch name>创建新的分支;git switch <branch name>切换到指定分支
    也可以用git checkout -b <new branch name>创建新的分支并切换到该分支,与上面两条等价

    git reset --hard <版本ID前7位> 在新版本和历史版本之间来回切换,如果想从旧版本(当前)回到最新版本但git log又查询不到当前版本之后的版本记录,此时可以用git reflog查询所有版本,从而回到最新版本

    git checkout -- <file> 放弃工作区的文件修改

    git reset HEAD 放弃暂存区的内容(也就是add但没commit的内容)

    rm <file> 删除文件,如果想历史版本中的这个文件记录也删除掉,可以commit一下,在commit之前想找回该文件的话可以用git checkout <file>

    忽略一个文件夹中除某个文件以外的所有其他文件:
    文件结构如下:
    /
    |--top
      |--other
      |--mid
        |--other1
        |--other2
        |--...
        |--low
          |--dont_igore.me
          |--other1.x
          |--other2.x
          |--...

    .gitignore中这么写:
    top/*
    !top/mid/
    top/mid/*
    !top/mid/low/
    top/mid/low/*
    !top/mid/low/dont_ignore.me

    错误写法:

    top/*

    !top/mid/low/dont_ignore.me

  • 相关阅读:
    卧槽!缓存的问题太多了(雪崩、击穿、穿透…)一个个解决!
    Java 命名规范(非常全面,可以收藏)
    一次接口超时排查,花费了我两个星期。。
    LiveGBS和海康威视
    SQLite文件存储和读取
    Vue页面刷新原理:Cesium刷新机制
    MBtiles格式数据
    gitee:403错误
    uniapp是什么?
    HBuilderx怎么运行代码
  • 原文地址:https://www.cnblogs.com/uestcliming666/p/11965117.html
Copyright © 2011-2022 走看看