• Meet Github


    Source: http://www.liaoxuefeng.com/

    Here only the local part.

    Install on windows

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

    Establish repository

    # Making an empty directory
    $ mkdir learngit
    $ cd learngit
    # display current working directory
    $ pwd
    # Making the current directory a Git-managed one. Don't change the directory
    # .git (version repository)
    $ git init
    Initialized empty Git repository in /Users/michael/learngit/.git/
    $ ls -ah   # list hide folders
    

    Add files into the repository

    # Add files into current working directory
    $ git add readme.txt
    # Add annotations of this submission
    $ git commit -m "wrote a readme file"
    # Submit multiple files at one time
    # Actually, *add* operation is to submit the file to *stage* (working area,
    # store the files currently worked on) in the repository (/.git), and 
    # *commit* will move the ones from *stage* to current branch (git will 
    # automatically create one named *master* for us (*HEAD* is a pointer
    # pointing to master).
    $ git add file2.txt file3.txt
    $ git commit -m "add 3 files."
    # Check the differences between the most recent file in the repository and 
    # the one in stage.
    $ git diff HEAD -- readme.txt
    

    Change the files in the repository

    # Check current status of the file
    $ git status readme.txt
    # Check the changes
    $ git diff readme.txt
    # If the changes agreed
    $ git add readme.txt
    $ git commit -m "One change"
    

    Version swap

    # Check history changes, note that a more clear time line could be seen in GUI
    $ git log
    $ git log --pretty=oneline
    # Swap back to the last version, HEAD^^ denotes the penultimate version, and 
    # HEAD~100 denotes the last 100th version
    $ git reset --hard HEAD^
    # Recover recent versions
    # If the command window is not closed after swapping back, the newer version 
    # could be recovered using the commit ID (first few numbers are enough; you 
    # could look up to it at the log checked before)
    $ git reset --hard 3628164
    # If the command window has been closed after swapping back, the command below
    # could trace command history, thus you could find the commit ID of the newer
    # file.
    $ git reflog
    # Back to the version for most recent *add* or *commit*
    $ git checkout -- test.m
    # Fetch the file most recently submitted to *master* to *stage*, then repeat 
    # line above.
    $ git reset HEAD test.m
    

    Deletion

    # Delete the file directly in the working area
    $ rm test.m
    # Current status: but the file is not removed from repository
    $ git status
    # Delete the file from repository
    $ git rm test.txt
    $ git commit -m "Confirm deletion"
    # Or cancel the deletion
    $ git checkout -- test.txt
    
  • 相关阅读:
    个推微服务网关架构实践
    NB-IoT 的“前世今生”
    个推基于Consul的配置管理
    个推Node.js 微服务实践:基于容器的一站式命令行工具链
    个推用户画像的实践与应用
    TensorFlow分布式实践
    个数是如何用大数据做行为预测的?
    QCon技术干货:个推基于Docker和Kubernetes的微服务实践
    基于CMS的组件复用实践
    数据可视化:浅谈热力图如何在前端实现
  • 原文地址:https://www.cnblogs.com/minks/p/5594289.html
Copyright © 2020-2023  润新知