• My learn of git


    这篇文章记录我从零开始学习git的过程.

    我的git最开始是在廖雪峰git教程学习的。

    安装git

    我的git是在github 下载的mysysgit 然后打开安装包,一路点下去就好了。

    然后就可以在右键菜单里面发现git bash的选项了。

    git-bash-示例

    学习基本的git命令

    我第一个学会的命令是 git init

    git-init-命令示例

    然后是 git config 命令

    git config --global user.name "sparkrat"
    git config --global user.email "sparkrat@163.com"
    

    这个设置很重要哦@O_O@/

    git-config-命令示例

    然后可以在这个文件夹里面做一些事情,例如写一些代码什么的。。

    接下来的命令就是 git addgit commit
    我一般直接用

    git add --all
    git commit -m "a hint message"
    

    菜鸟无需知道太多技巧,用多了以后慢慢就知道了。。

    一些必须掌握的命令

    然后我现在还掌握的命令有

    git status
    git rm < a file >
    git checkout -- < a file >
    git clone remoteReponame
    git remote add remoteReponame remoteRepoAddress
        # remoteRepoAddress 可以有多种协议,最常用的有两种:
        # 使用https协议: https://github.com/username/reposityName.git     
        # 使用ssh协议:   git@github.com:username/reposityName.git   
    git push remoteReponame brachName
    git remote remove remoteReponame
    git reset --hard HEAD(^(^(^)))
    git log (--pretty=oneline)
    git reflog (--pretty=oneline)
    

    使用sshkey让push更方便

    还有,不得不说的一件事就是,一开始我一直用的https协议进行push的,但是这样麻烦死人。因为每次都需要输github账号密码。后来我发现,用shh协议可以想push就push。。炒鸡方便嗄。

    首先,用 ssh-keygen -t rsa -C "youremail@example.com" 生成一个rsa文件,在用户文件夹的.ssh文件夹(好像是隐藏文件夹)里面。
    生成的时候所有的选择都选择默认,看到下面的内容的时候说明生成成功了。

    ssh-keygen-命令示例

    用记事本打开id_rsa.pub(公钥),把文件内容复制到github的-用户设置-SSHkeys-addkey里面。

    添加rsa公钥到github示例

    这样之后在往github上push你的repo就不需要再输入账号密码。

    用git pages搭建博客

    学会用git和github的remoteRpo之后,用它来干点什么呢?

    当然是弄个pages博客啦啦啦。

    1. 首先去找一个模板吧,去github的搜索框里面搜jekyll关键字!!
      嘎嘎嘎一堆模板出来了。
    2. 然后clone到你的电脑吧。
    3. 再然后新建一个名字叫做yourusername.github.io的repo吧。
    4. 然后把你在第二步里面clone下来的repo名字改成yourusername.github.io吧
    5. 把修改好的repo push到你的github里面吧!!
    6. 然后在浏览器地址栏里面输入yourusername.github.io看看效果吧。
    7. 给你的博客修改样式,添加文章吧。

    我的git学习之路大致就是这样的了。 还有就是,如果想用github的pages搭建博客,markdown不能不学啊。

    当然,知道一些基础的语法就可以了,不需要学的很深入。markdown的学习可以穿插在写博客文章的中间,慢慢学。

    程序猿,你要学的东西还很多,慢慢学吧。


    update 2015-06-03

    the new command I learned

    git checkout -b newbranch      //create a new branch and switch to it
        //it also equal to the next two command
    git branch newBranchName       //create a new branch
    git chekcout branchName        //switch to a brach
    git remote show remotereponame //see the details of remote repo
    git merge branchName           //merge a branch to current brach
    
  • 相关阅读:
    用R语言完成的交通可视化报告
    二维码(带有图片)的生成
    大文件数据去重复
    shell 脚本大文件处理
    Domain-specific language 领域特定语言
    cacheed 限制 4节点 3000万 es 批量删除 shell脚本练习 elasticsearch_action
    cached
    广告中嵌入非广告 非广告中嵌入广告
    js 四种调用方式 Method Invocation Pattern
    js 变量作用域
  • 原文地址:https://www.cnblogs.com/SparkRat/p/4570375.html
Copyright © 2020-2023  润新知