zoukankan      html  css  js  c++  java
  • 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
    
  • 相关阅读:
    还是不能偷懒ForEach陷阱
    备忘ForEach方法与foreach迭代器使用小区别
    备忘反射调用Private方法
    机器人也会梦见电子羊吗
    Windows 7 下Skype最小化到系统托盘
    编译Boost_1_37_0 For VS2008
    使用API判断网络是否连通(InternetGetConnectedState / IsNetworkAlive)
    SVN中“txncurrentlock:拒绝访问”错误
    幂函数的非递归算法
    Visual Studio中的文件类型(sln vcproj suo user ncb)
  • 原文地址:https://www.cnblogs.com/minks/p/5594289.html
Copyright © 2011-2022 走看看