• git 使用笔记


    首先设置个人信息,打开git bash

    $ git config --global user.name "Your Name"
    $ git config --global user.email "email@example.com"

    新建git目录,打开git bash

    $mkdir learngit
    
    $cd d:/learngit/
    
    $pwd
    
    d/learngit/

    通过git init 把该目录变成git管理仓库

    $ git init
    Initialized empty Git repository in /Users/michael/learngit/.git/

    把一个文件放到Git仓库只需要两步, 第一步,用命令git add告诉Git,把文件添加到仓库:

    $ git add readme.txt

    第二步,用命令git commit告诉Git,把文件提交到仓库:

    $ git commit -m "wrote a readme file"
    [master (root-commit) eaadf4e] wrote a readme file
     1 file changed, 2 insertions(+)
     create mode 100644 readme.txt

    补充:

    git status命令可以让我们时刻掌握仓库当前的状态

    git diff顾名思义就是查看difference

    git log命令显示从最近到最远的提交日志, 加上--pretty=oneline参数为简略显示

    $ git log
    commit 1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master)
    Author: Michael Liao <askxuefeng@gmail.com>
    Date:   Fri May 18 21:06:15 2018 +0800
    
        append GPL
    
    commit e475afc93c209a690c39c13a46716e8fa000c366
    Author: Michael Liao <askxuefeng@gmail.com>
    Date:   Fri May 18 21:03:36 2018 +0800
    
        add distributed
    
    commit eaadf4e385e865d25c48e7ca9c8395c3f7dfaef0
    Author: Michael Liao <askxuefeng@gmail.com>
    Date:   Fri May 18 20:59:18 2018 +0800
    
        wrote a readme file
    
    $ git log --pretty=oneline
    1094adb7b9b3807259d8cb349e7df1d4d6477073 (HEAD -> master) append GPL
    e475afc93c209a690c39c13a46716e8fa000c366 add distributed
    eaadf4e385e865d25c48e7ca9c8395c3f7dfaef0 wrote a readme file

    回退到上一个版本add distributed

    $ git reset --hard HEAD^
    HEAD is now at e475afc add distributed

    回退到任意一个版本git reset --hard 版本号(可以只输入前几位,能够区分即可)

    $ git reset --hard 1094a
    HEAD is now at 83b0afe append GPL

    重返未来,可以用git reflog查看历史命令, 以便确定要回到哪个版本号.

  • 相关阅读:
    如何修改运行中的docker容器的端口映射和挂载目录
    kubernetes集群应用部署实例
    linux centos7磁盘格式化挂载之parted
    mysql授权用户,撤销用户,撤销权限基本操作
    MySQL数据库基础备份
    实现Kubernetes跨集群服务应用的高可用
    使用Harbor配置Kubernetes私有镜像仓库
    kubernetes1.5新特性(二):支持Photon卷插件
    kubernetes1.4新特性(一):支持sysctl命令
    说说我心中的Linux系统
  • 原文地址:https://www.cnblogs.com/feng-hao/p/11386294.html
Copyright © 2020-2023  润新知