My learn of git

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

安装git

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

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


学习基本的git命令

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

然后是 git config 命令

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

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

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

接下来的命令就是 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文件夹(好像是隐藏文件夹)里面。
生成的时候所有的选择都选择默认,看到下面的内容的时候说明生成成功了。

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

这样之后在往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

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

——-update at 2015-06-03 08:50

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值