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

    由于版本的不同,列出常用几个方法:

    1. git help 
    2. git help <command 命令>
      如:git help clean 
      NAME
             git-clean - Remove untracked files from the working tree
      
      SYNOPSIS
             git clean [-d] [-f] [-i] [-n] [-q] [-e <pattern>] [-x | -X] [--] <path>...
      
      
      DESCRIPTION
             Cleans the working tree by recursively removing files that are not under version control, starting from the current directory.
      
             Normally, only files unknown to Git are removed, but if the -x option is specified, ignored files are also removed. This can, for example,
             be useful to remove all build products.
      
             If any optional <path>... arguments are given, only those paths are affected.
      
      OPTIONS
             -d
                 Remove untracked directories in addition to untracked files. If an untracked directory is managed by a different Git repository, it is
                 not removed by default. Use -f option twice if you really want to remove such a directory.
      
             -f, --force
                 If the Git configuration variable clean.requireForce is not set to false, git clean will refuse to delete files or directories unless
                 given -f, -n or -i. Git will refuse to delete directories with .git sub directory or file unless a second -f is given.
      
             -i, --interactive
                 Show what would be done and clean files interactively. See "Interactive mode" for details.
      
             -n, --dry-run
                 Don't actually remove anything, just show what would be done.
      
             -q, --quiet
      View Code
    3. git help -a && git help -g
      -  git help 命令行 git help <concept>概念(git help -g :常见的Git指南)
      'git help -a''git help -g'列出了可用的子命令和一些概念指南。
      请参阅“ git help <命令>”或“ git help <概念>”以了解特定的子命令或概念。
      View Code
    4. usage
      git [--version] [--help] [-C <path>] [-c <name>=<value>]
                 [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
                 [-p | --paginate | -P | --no-pager] [--no-replace-objects] [--bare]
                 [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
                 <command> [<args>]
      View Code
    • git config --global credential.helper store记住密码
    • git config user.name xxx配置帐号
    • git config user.email xxx配置邮箱
    • git pull合并
    • git push提交
    • git add .添加
    • git merge --abort恢复
    • git reset merge合并重置
    • git commit -m “xx”提交本地
    • git checkout origin xxx切换分支
    • git branch 查看当前分支
    • git  diff  
      可以查看当前没有add 的内容修改(不在缓冲区的文件变化
    • git diff --cached
      查看已经add但没有commit 的改动(在缓冲区的文件变化)
    • git diff HEAD
      是git  diff   &&  git diff --cached 两条命令的合并
    • git tag -d v1.2.1
      删除指定tags
    • git tag v2.0.6
      创建 tags (基于commit ,请先commit 然后创建)
    • git push origin --tags 
      提交tags
    • git tag -a v0.9 9ff91da
      为已经提交的代码打上tag,下面命令使用到
      git log --oneline --decorate --graph
      的乱码(注意一般是日志的第一行也就是最新一次提交的编码)
    • git remote update origin --prune  Git更新远程分支列表
    • 仓库备份:
      git clone --mirror <ssh> (git@git.coding.net:yjwb/magento2-mc.git)  

      备份还原:
      git clone <ssh:name库名称.git> (magento2-mc.git) 
      

        

      备份更新:
      git --git-dir=/<目录>/<ssh:name 库名称.git>(magento2-mc.git) remote update
      

       

    • 克隆祼仓库:
      git clone --bare <ssh> (git@git.coding.net:yjwb/magento2-mc.git)  
    • git reset --hard 还原上次
    • git reset --hard HEAD 还原指定commit
    • git reflog 查看commit历史
    • git reset HEAD .   撤销本地所有add操作
    • git reset HEAD -name 撤销add操作的某个文件或目录:
    • git clean -d -fx 清除本地没有被add的内容
    • 更新 git 子版本库管理:git submodule update;
    • 添加 git 子版本库管理; 
      1、git submodule add 子树GIT地址 目录/+项目名 ;
      2,项目会自动生成 .gitmodules 文件;
  • 相关阅读:
    Dubbo之SPI实现原理详解
    Java SPI详解
    Java是如何实现自己的SPI机制的
    Dubbo的负载均衡原理解析
    Dubbo公开课
    【todo】什么是沟子函数
    一步一图,带你走进 Netty 的世界!
    https://github.com/xiaojiaqi/k8seasy_release_page
    mysql 8.0导致5.6数据后 :ERROR 1449 (HY000): The user specified as a definer ('mysql.infoschema'@'localhost') does not exist
    Ansible 日常使用技巧
  • 原文地址:https://www.cnblogs.com/q1104460935/p/8571840.html
Copyright © 2011-2022 走看看