博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
git简明使用
阅读量:5743 次
发布时间:2019-06-18

本文共 1743 字,大约阅读时间需要 5 分钟。

程序开发你会需要代码管理工具,fast version control 那就是git了。
一、本地测试
首先下载gi
t  
安装好后打开bash开始体验一下:
  创建用户配置
  $ git config --global user.name "you name"
  $ git config --global user.email youemail@yahoo.com
  看一下配置
  $ git config --list
  可以看到你刚刚配的用户名、email
  $ git help
  有很多的cmmand 
 
简单的体验一下:
1.创建一个repository
在电脑e盘建一个文件夹 log
$ cd /e/log
$ git init
2.在log目录新建编辑一个文件tin.txt (在工作区) ,并提交到repository
$ git add tin.txt                          (加到缓存区)
$ git commit -m 'first commit'        (提交到仓库)
3.修改一下tin.txt ,并执行 add 和 commit的命令,
看下两次版本的记录
$ git log
 
commit 5cd41c8f0c0f1b798cde1ef4ee71e41269c3c43a

Author: tinin <tintindeng@gmail.com>

Date: Tue Sep 16 13:24:54 2014 +0800

modified tin

commit 8175e287683f37e905cb9056838ac068c298418c

Author: tinin <tintindeng@gmail.com>
Date: Tue Sep 16 13:14:26 2014 +0800

first

4.回到修改前的版本
$ git reset --hard 8175e
 
HEAD is now at 8175e28 first
看下版本记录
$ git log --pretty=oneline

8175e287683f37e905cb9056838ac068c298418c first

5.回到修改后的版本

先看下啊版本记录

$ git reflog

8175e28 HEAD@{0}: reset: moving to 8175e

5cd41c8 HEAD@{1}: commit: modified tin
8175e28 HEAD@{3}: commit (initial): first

$ git reset --hard 5cd41

又回来了

 

二、远程连接github

github地址 

注册好帐号并登录

1.create一个仓库(小加号)

找到仓库的连接拷贝下来

2.同过git命令行clone仓库到本地

$ git clone https://github.com/tintindeng/androidexample.git

3.远程提交代码

生成密钥(用来提交代码安全认证)

$ ssh-keygen -t rsa -C 'tintindeng@gmail.com'

....
The key's randomart image is:
+--[ RSA 2048]----+
| .o*+* |
| +.O B |
| + * * |
| . o + . |
| . . S |
| . . |
| E . . . |
| . . |
| |
+-----------------+

接下来到github上添加你生成的publickey

关联到远程仓库 和push到仓库

$ git remote add origin https://github.com/tintindeng/androidexample.git

$ git push origin master          (输入你的用户名密码)

在github你的仓库下可以看到你提交的文件了

另外github提供了图像化界面客户端  首页就看到下载的button

可以down下来体验下

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

转载于:https://www.cnblogs.com/tintindeng/p/3975023.html

你可能感兴趣的文章
EditText插入QQ表情源码
查看>>
ASP.NET core 搭建于 Deepin 2015.4 记录
查看>>
斐讯 K3C V32.1.45.267 V1.1官改升级操作
查看>>
Krpano 全景生成-droplet
查看>>
Krpano 开启多边形编辑模式
查看>>
无法登录域
查看>>
我的友情链接
查看>>
CCNA学习指南第四章
查看>>
解决案例之烟台富士康
查看>>
hibernate二级缓存简单介绍
查看>>
Linux系统信息查看命名
查看>>
我的友情链接
查看>>
shell for读取文件换行问题
查看>>
python 文件处理模块的使用,如何读取文件中数据
查看>>
JAVA线程14 - 新特性:同步工具
查看>>
ubuntu14.04下docker学习笔记
查看>>
运维是什么!
查看>>
请妥善保管自己的QQ等网络帐号
查看>>
[原创]windows server 2012 AD架构 试验 系列 – 15解决AD复制冲突
查看>>
生成签名
查看>>