• git和github


    安装GIT

      sudo apt-get install git

      [root@s1-61526 /]# git --version                                                                     
        git version 1.7.1                                                                                    
      [root@s1-61526 /]# 
     


    初始化一个Git仓库,使用git init命令。

    添加文件到Git仓库,分两步:

    • 第一步,使用命令git add <file>,注意,可反复多次使用,添加多个文件;

    • 第二步,使用命令git commit,完成。

    • 如下:
    [root@s1-61526 git_trainning]# ls                                                                    
    first_git.txt                                                                                        
    [root@s1-61526 git_trainning]#                                                                       
    [root@s1-61526 git_trainning]# vim file1.txt                                                         
    [root@s1-61526 git_trainning]# git add file1.txt                                                     
    [root@s1-61526 git_trainning]# git commit -m "add file1.txt"                                         
    [master e855407] add file1.txt                                                                       
     Committer: root <root@s1-61526.(none)>                                                              
    Your name and email address were configured automatically based                                      
    on your username and hostname. Please check that they are accurate.                                  
    You can suppress this message by setting them explicitly:                                            
                                                                                                         
        git config --global user.name "Your Name"                                                        
        git config --global user.email you@example.com                                                   
                                                                                                         
    If the identity used for this commit is wrong, you can fix it with:                                  
                                                                                                         
        git commit --amend --author='Your Name <you@example.com>'                                        
                                                                                                         
     1 files changed, 1 insertions(+), 0 deletions(-)                                                    
     create mode 100644 file1.txt                                                                        
    [root@s1-61526 git_trainning]#                   

    git status

    • 要随时掌握工作区的状态,使用git status命令。

    • 如果git status告诉你有文件被修改过,用git diff可以查看修改内容。

    • 例如,对file1.txt做了修改后,可以通过diff命令查看具体修改的内容,如下:
    git diff file1.txt

    diff
    --git a/file1.txt b/file1.txt index e212970..582e430 100644 --- a/file1.txt +++ b/file1.txt @@ -1 +1,3 @@ file1 +Git is a distributed version control system. +Git is free software. [root@s1-61526 git_trainning]# [root@s1-61526 git_trainning]# git add file1.txt [root@s1-61526 git_trainning]# git status # On branch master # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # modified: file1.txt # [root@s1-61526 git_trainning]# git commit -m "add distributed" [master b70b785] add distributed 1 files changed, 2 insertions(+), 0 deletions(-) [root@s1-61526 git_trainning]# git status # On branch master nothing to commit (working directory clean) [root@s1-61526 git_trainning]#

    查看更新的版本

    $ git log
    commit 132b65ebbc959887f3dceda9342692b85cc0cbd6
    Author: ligq <noube@qq.com>
    Date:   Thu Mar 9 20:05:38 2017 +0800
    
        hoho
    
    commit ac3de534b8e82e5d98734f5e2dda2b6c54694c85
    Author: ligq <noube@qq.com>
    Date:   Thu Mar 9 20:02:35 2017 +0800
    
        forgive me
    
    commit ba084157d3b74b044c29c79116c079bc72d5322a
    Author: ligq <noube@qq.com>
    Date:   Thu Mar 9 19:54:33 2017 +0800
    
        test
    
    commit 0388642f31eaf542228c9d7f22b1dbc2aa48b708
    Author: ligq <noube@qq.com>
    Date:   Thu Mar 9 19:53:02 2017 +0800
    
        first using git
    
    ligq@DESKTOP-4SLI49M MINGW64 ~/git_trainning (master)
    $
    普通方式
    ligq@DESKTOP-4SLI49M MINGW64 ~/git_trainning (master)
    $ git log --pretty=oneline
    132b65ebbc959887f3dceda9342692b85cc0cbd6 hoho
    ac3de534b8e82e5d98734f5e2dda2b6c54694c85 forgive me
    ba084157d3b74b044c29c79116c079bc72d5322a test
    0388642f31eaf542228c9d7f22b1dbc2aa48b708 first using git
    
    ligq@DESKTOP-4SLI49M MINGW64 ~/git_trainning (master)

    回滚

    #回滚到指定版本
    $ git reset --hard 132b65e
    HEAD is now at 132b65e hoho
    
    #回滚到上一个版本
    $ git reset --hard HEAD^
    HEAD is now at 0388642 first using git

  • 相关阅读:
    Linux 守护进程一
    Linux 改进捕捉信号机制(sigaction,sigqueue)
    Linux 发送信号
    Linux 信号捕捉
    Heartbeat+DRBD+MFS高可用
    centos7 MFS drbd keepalived
    RabbitMQ-官方指南-RabbitMQ配置
    CentOS 7 单用户模式+救援模式
    CentOS6.8 x64+Nginx1.3.8/Apache-httpd 2.4.3+PHP5.4.8(php-fpm)+MySQL5.5.28+CoreSeek4.1源码编译安装
    nginx定制header返回信息模块ngx_headers_more
  • 原文地址:https://www.cnblogs.com/noube/p/6523660.html
Copyright © 2020-2023  润新知