Git——从安装到连接GitHub
安装Git
Windows平台上很轻松的,直接点击地址Git下载进行下载,之后基本就是下一步,安装成功。
在所需要操作的项目下右键,点击“Git Bash Here”弹出Git命令窗口即可。
我用的是CentOS系统,具体操作:
[admin@localhost ~]$ yum install curl-devel expat-devel gettext-devel
提示需要root权限才能执行命令,用 su root 切换,之后重试,开始下载Git,下载成功后,执行:
[root@localhost admin]# git --version
git version 1.8.3.1
显示了版本号既表示安装成功
配置Git
配置用户名和邮箱,具体代码:
[root@localhost admin]# git config --global user.name 'your name' //用 --global 后,以后的项目都默认使用这里配置的信息
[root@localhost admin]# git config --global user.email 'your email' //如果要在某个项目中使用其他名字,去掉 --global 即可
配置之后输入 git config --list 获取已有的配置信息
输入 vim ~/.gitconfig 编辑配置信息
注意:在编辑模式下,点击 esc 后,光标不再闪烁,输入 :wq 回车退出编辑模式
Git创建仓库
git init 命令来初始化一个 Git 仓库,执行此命令之后:
初始化空的 Git 版本库于 /home/admin/.git/ //显示.git文件的位置
但是,目录下并没有发现 .git 文件,执行 ls -a 命令后:
[admin@localhost gitspace]$ ls -a
. .. .git README.txt
出现了 .git 文件.
注:ls -a 将显示的文件和隐藏的文件都显示出来了
创建README.txt文件时,用命令创建是无效的,由于命令mkdir创建的都是文件夹,故手动创建README.txt文件,之后:
$ git add README.txt
将该文件添加到仓库中,建立对该文件的跟踪,执行命令git status :
# 位于分支 master
#
# 初始提交
#
# 要提交的变更:
# (使用 "git rm --cached <file>..." 撤出暂存区)
#
# 新文件: README.txt
#
git commit 执行 git commit 将缓存区内容添加到仓库中,用“ ”备注信息:
[admin@localhost gitspace]$ git commit -m "add readme"
git clone 从现有的Git仓库中拷贝项目:
git clone <Git仓库> <本地目录> //没有本地目录则克隆到默认目录
[admin@localhost gitspace]$ git clone https://github.com/tongxue001/TestPHP.git
正克隆到 'TestPHP'...
remote: Enumerating objects: 21, done.
remote: Counting objects: 100% (21/21), done.
remote: Compressing objects: 100% (14/14), done.
remote: Total 21 (delta 5), reused 10 (delta 2), pack-reused 0
Unpacking objects: 100% (21/21), done.
git add git add 命令可将该文件添加到缓存
[admin@localhost TestPHP]$ touch README
[admin@localhost TestPHP]$ touch hello.php
caishuzi.php _config.yml demo.php hello.php README README.md
[admin@localhost TestPHP]$ git status -s
?? README
?? hello.php
[admin@localhost TestPHP]$ git add README hello.php
[admin@localhost TestPHP]$ git status -s
A README
A hello.php
git status git status 以查看在你上次提交之后是否有修改,加了-s之后以获得的简短结果输出。
git reset HEAD git reset HEAD 命令用于取消已缓存的内容。
git rm -f 强力删除文件
git mv git mv 命令用于移动或重命名一个文件、目录、软连接。
查看CentOS下的ssh密钥
使用rsa进行加密:
[admin@localhost gitspace]$ ssh-keygen -t rsa
连续回车,得到对应的image,然后进入.ssh文件
[root@localhost gitspace]# cd /root/.ssh
通过[root@localhost .ssh]# cat /root/.ssh/id_rsa.pub 该命令获取密钥,在GitHub中setting中的SSH and GPG keys中的New SSH key添加密钥,最后在终端输入:
[root@localhost gitspace]# ssh -T git@github.com //可能我的是虚拟机操作的,它提示了:
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
RSA key fingerprint is MD5:16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
最后,感人的一幕:
Hi tongxue001! You've successfully authenticated, but GitHub does not provide shell access.
连上去了哈哈哈,今天的博客就到这里啦~~~
Git——从安装到连接GitHub的更多相关文章
- ubuntu下git安装及连接github
1.安装 sudo apt-get install git git-core git-gui git-doc git-svn git-cvs gitweb gitk git-email git-dae ...
- git的安装已经连github
https://help.github.com/articles/generating-ssh-keys 1.安装git [plain] view plain copy sudo apt-get ...
- git下载、安装、连接github
0.下载git 官网下载速度慢,下载不下来阿里云下载地址:https://npm.taobao.org/mirrors/git-for-windows/ 1.安装git linux:在命令行直接输入: ...
- Git:四、连接GitHub远程仓库
1.拥有一个GitHub网站的账号 2.创建SSH Key 打开终端(Windows打开Git Bash),输入: ssh-keygen -t rsa -C "youremail@??.co ...
- Git使用:Linux(Ubuntu 14.04 x64)下安装Git并配置连接GitHub
github是一个非常好的网络代码托管仓库,知晓许久,但是一直没有用起来,最近才开始使用git管理自己的文档和代码. Git是非常强大的版本管理工具,今天就告诉大家,如何在Linux下安装GIt,并且 ...
- 安装 Git 并连接 Github
下载安装 Git, 下载地址:https://git-scm.com/download/win . 在命令行中输入 git 测试 Git 是否安装成功. 在桌面鼠标右击打开 Git Bash Here ...
- 转:sublime上使用git连接github
"工欲善其事,必先利其器." 这是古人的教诲,也是一个高效率的工程师需要遵循的法则之一.从大学开始写Java使用了JBuilder,Eclipse,后来写PHP用了Zend,写Ja ...
- WebStorm和sublime上使用git连接github(转)
WebStorm使用git连接github的方法: 用webstorm上传代码时,首先要先下载git,网址一搜就可以搜到,安装git,并且把ssh配置到github上.然后开始配置webstorm,打 ...
- Sublime Text 中使用Git插件连接GitHub
sublime Text的另一个强大之处在于它提供了非常丰富的插件,可以帮助程序员来适合大多数语言的开发.这些插件通过它自己的Package Controll(包管理)组件来安装,非常方便.一般常用的 ...
随机推荐
- Java—io流之打印流、 commons-IO
打印流 打印流根据流的分类: 字节打印流 PrintStream 字符打印流 PrintWriter /* * 需求:把指定的数据,写入到printFile.txt文件中 * * 分析: * 1, ...
- scss @mixin & @include
定义一个带参数和默认值的mixin class // demo.scss @mixin button($background:#606266) { font-size: 1em; padding: 0 ...
- Js~对键值对操作
键值对主要是面向对象语言里的字典,或者叫哈希表,它通过键(key)可以直接访问到值(value),所以它查找的时间复杂度是O(1),即一次查找即可找到目标:在.net里有Dictionary,而在ja ...
- Django context must be a dict ranther than Context
1.1 错误描述 TypeError at /time/ context must be a dict rather than Context. Request Method: GET Request ...
- name 'xrange' is not defined
出现这个错误是因为examples使用的是Python2 在Python3中,移除了在Python2中的range, 并将 xrange 命名为 range 将代码中的xrange改为range就可以 ...
- css两种常用的不定宽高的水平垂直居中方法,记住它,不再为样式发愁
css 几种常用的简单容易记住的水平垂直居中方法 前言 正文 第一种方法 第二种方法 结束语 前言 我们在设计网页时,会大量的运用到水平垂直居中,如果知道元素的宽高,那水平垂直居中是很简单的,无非是用 ...
- SpringBoot集成Junit
1.在pom.xml下添加Junit依赖: <!--添加junit环境的jar包--> <dependency> <groupId>org.springframew ...
- Mybatis_day3
三 使用XML配置SQL映射器(映射文件) 关系型数据库和SQL是经受时间考验和验证的数据存储机制.和其他的ORM 框架如Hibernate不同,[MyBatis鼓励]开发者可以直接[使用数据库],而 ...
- Finding the Right EAV Attribute Table
$customer = Mage::getModel('catalog/product'); $entity = $customer->getResource(); $attribute = M ...
- IDEA run/debug configurations中没有配置tomcat选项
原文链接:https://blog.csdn.net/qq_41016818/article/details/80871738 原因分析 没有配置tomcat插件 解决方法如下: file->s ...