GitHub实战系列~1.环境部署+创建第一个文件 2015-12-9

简介:

GitHub实战系列汇总:http://www.cnblogs.com/dunitian/p/5038719.html

——————————————————————————————————————————————————————

很多人问,明明有git gui 和 github可以直接图形化操作的吗?全部指令干啥???

呃(⊙o⊙)…呃(⊙o⊙)… ===> 装逼~

O(∩_∩)O~,开玩笑的,其实就是为了通用和熟悉git,linux里面照样这样用,多熟悉点基础指令很有用的,

如果觉得顿时不开心了、无爱了==>推荐你快速入门:http://www.imooc.com/learn/390

———————————————————————————————————————————————————————

安装系列:

软件下载:http://git-scm.com/download/

环境搭建:(比较简单,看图)

下面是命令模式,需要一点点linux基础(Linux基础学习),没有也没事,看详解

1.我们看看git的配置都有哪些:

git config
————————————————————————————————————————
usage: git config [<options>]

Config file location
--global use global config file
--system use system config file
--local use repository config file
-f, --file <file> use given config file
--blob <blob-id> read config from given blob object

Action
--get get value: name [value-regex]
--get-all get all values: key [value-regex]
--get-regexp get values for regexp: name-regex [value-regex]
--get-urlmatch get value specific for the URL: section[.var] URL
--replace-all replace all matching variables: name value [value_rege x]
--add add a new variable: name value
--unset remove a variable: name [value-regex]
--unset-all remove all matches: name [value-regex]
--rename-section rename section: old-name new-name
--remove-section remove a section: name
-l, --list list all
-e, --edit open an editor
--get-color find the color configured: slot [default]
--get-colorbool find the color setting: slot [stdout-is-tty]

Type
--bool value is "true" or "false"
--int value is decimal number
--bool-or-int value is --bool or --int
--path value is a path (file or directory name)

Other
-z, --null terminate values with NUL byte
--name-only show variable names only
--includes respect include directives on lookup

————————————————————————————————————————
2.设置名字:


git config --global user.name "你的名字"

3.设置邮箱:
git config --global user.email "你的邮箱"

————————————————————————————————————————
4.输出更显目的设置
git config --global color.ui auto


5.如果忘记自己的配置,就用这个命令来查看一下


cat ~/.gitconfig

————————————————————————————————————————
[user]
name = 你的名字
email = 你的邮箱
[color]
ui = auto
————————————————————————————————————————
6.设置SSH Key


ssh-keygen -t rsa -C "你的邮箱"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/DNT_PC/.ssh/id_rsa): 回车一下
/c/Users/DNT_PC/.ssh/id_rsa already exists.
Overwrite (y/n)? 回车一下
————————————————————————————————————————
7.记不得key用这个指令:

$ cat ~/.ssh/id_rsa.pub
————————————————————————————————————————
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQD3joLDvLaBHnP4aMJwcjo6gjcipBoOnCzETPkQBu+LdBit8L3CSltQ6AhgOL8xcUHxR+ZojdNhd0XXvOfIfuPJVBH57dqptvAeqDkQHiBE5lX2/7pjPVPHSeTiQd0ijYtc1HxtqMo4U++sR6M7QYXPFnHBogUmZdxItVWr***********************4H2h19aIUImZU2KLndgP1AYGFh1FsprWO0oa6ebsIsPGtgrtHqBfHd9e2yF0/1fIFhidXgGvgmt4K9nO0WJ24vW****************
————————————————————————————————————————
8.在github里面添加密钥(公共)


————————————————————————————————————————
9.用手中的私人密钥和github验证


ssh -T git@github.com
————————————————————————————————————————
The authenticity of host 'github.com (192.30.252.128)' can't be established.
RSA key fingerprint is SHA256:nThbg6k*************************viKw6E5********.
Are you sure you want to continue connecting (yes/no)? 输入yes
Warning: Permanently added 'github.com,192.30.252.128' (RSA) to the list of known hosts.
Hi 你的姓名! You've successfully authenticated, but GitHub does not provide shell access.
————————————————————————————————————————
10.在github里面创建一个公开仓库(私有的收费)并初始化仓库(最下面的复选框,最下面的两个下拉列表后面说)


————————————————————————————————————————
11.复制一份github ssh库的地址,一会儿有用


————————————————————————————————————————
12.克隆一份到本地

git clone git@github.com:dunitian/test.git(刚才的地址)

————————————————————————————————————————
Cloning into 'test'...
Warning: Permanently added the RSA host key for IP address '192.30.252.131' to the list of known hosts.
remote: Counting objects: 3, done.
remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (3/3), done.
Checking connectivity... done.
————————————————————————————————————————
13.写点东西测试一下


cd test(项目名,注意大小写)

DNT_PC@DNT_PC-PC MINGW32 ~/test (master)
ls (查看当前目录有哪些东西)
README.md

DNT_PC@DNT_PC-PC MINGW32 ~/test (master)
vi dnt.txt (如果有dnt.txt的文件就打开,没有就创建一个dnt.txt的文件)

输入你想写的东西,i 进入编辑模式 ,按esc 输入 :wq 并回车 是保存 
————————————————————————————————————————
14.查看git的状态 (没提交,所以是untracked files状态)


git status
————————————————————————————————————————
On branch master
Your branch is up-to-date with 'origin/master'.
Untracked files:
(use "git add <file>..." to include in what will be committed)

dnt.txt

nothing added to commit but untracked files present (use "git add" to track)
————————————————————————————————————————
15.把文件提交到仓库


git add dnt.txt (添加到暂存区)

git commit -m "add first file to my git" (提交;引号里面是注释)
————————————————————————————————————————
[master 4e69105] add first file to my git
warning: LF will be replaced by CRLF in dnt.txt.
The file will have its original line endings in your working directory.
1 file changed, 1 insertion(+)
create mode 100644 dnt.txt
————————————————————————————————————————
16.到github看看,发现这个时候是木有添加我们的文件的(不要怕)


————————————————————————————————————————
17.查看提交日记 (吓死宝宝了,赶紧看看log)


git log
————————————————————————————————————————
commit 4e6910512df341e6d71d83607df8f44a6bd5a5b6
Author: dunitian <1054186320@qq.com>
Date: Wed Dec 9 22:26:44 2015 +0800

add first file to my git

commit 6f4fa43de0619c34345fb65d1b32ed887d4efd04
Author: dunitian <1054186320@qq.com>
Date: Wed Dec 9 21:30:07 2015 +0800

Initial commit
————————————————————————————————————————
18.原来是要push一下,更新github(如果发现command not found之类的问题再输入一遍就ok了)


git push
————————————————————————————————————————
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:

git config --global push.default matching

To squelch this message and adopt the new behavior now, use:

git config --global push.default simple

When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.

Since Git 2.0, Git defaults to the more conservative 'simple'
behavior, which only pushes the current branch to the corresponding
remote branch that 'git pull' uses to update the current branch.

See 'git help config' and search for 'push.default' for further information.
(the 'simple' mode was introduced in Git 1.7.11. Use the similar mode
'current' instead of 'simple' if you sometimes use older versions of Git)

Counting objects: 3, done.
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 294 bytes | 0 bytes/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git@github.com:dunitian/test.git
6f4fa43..4e69105 master -> master
————————————————————————————————————————

收工,媳妇催了。。。。明天继续

 

简单汇总一下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
————————————设置——————————————————
 
01.设置名字:
git config --global user.name  "你的名字"
 
02.设置邮箱:
git config --global user.email  "你的邮箱"
 
03.输出更显目的设置
git config --global color.ui auto
 
04.设置SSH Key
ssh -keygen -t rsa -C  "你的邮箱"
 
————————————基础——————————————————
 
05.克隆一份到本地
git clone git@github.com:dunitian /test .git( ssh 的项目地址)
 
06.把文件提交到仓库
git add dnt.txt (添加到暂存区)
git commit -m  "注释"  (提交)
 
07.push一下,更新github
git push
 
————————————查看——————————————————
 
08.查看自己的配置
cat  ~/.gitconfig
 
09.查看key
cat  ~/. ssh /id_rsa .pub
 
10.查看git的状态
git status
 
11.查看提交日记
git log
 
————————————其他——————————————————

  


本文转自毒逆天博客园博客,原文链接:http://www.cnblogs.com/dunitian/p/5034624.html,如需转载请自行联系原作者

相关文章
|
3月前
|
数据采集 缓存 JSON
GitHub 开源爆款工具|MediaCrawler:程序员零门槛采集抖音/小红书/B站等社交评论,30K star 背后的场景实战揭秘!
MediaCrawler 是一个支持多平台的社交媒体数据爬虫工具,覆盖小红书、抖音、B站等主流平台,提供关键词/ID爬取、评论采集、登录态缓存、代理池等功能,结合 Playwright 实现浏览器模拟,降低逆向难度,适合内容运营、数据分析等场景,开源免费,使用简便。
677 0
|
4月前
|
自然语言处理 关系型数据库 PostgreSQL
Github 10.1k star 的高颜值实时Kanban,看完就想收藏!引爆团队效率的开源利器:Planka 实战深度解析
Planka 是一款开源协作看板工具,支持多人实时协作、Markdown 编辑、通知提醒等功能。基于 MIT 许可,可自托管部署,适合中小团队和个人高效管理任务。
236 0
|
6月前
|
JSON JavaScript API
MCP 实战:用配置与真实代码玩转 GitHub 集成
MCP 实战:用配置与真实代码玩转 GitHub 集成
1397 4
|
搜索推荐 前端开发
使用VitePress创建个人网站并部署到GitHub
该网站使用 VitePress 构建,记录了前端开发相关的笔记和教程,涵盖 Vue2 和 Vue3 等内容。网站支持暗黑模式和 Algolia 搜索服务,提供了详细的导航和侧边栏配置。通过自动化脚本进行部署,托管于 GitHub Pages。
229 2
使用VitePress创建个人网站并部署到GitHub
|
JavaScript 搜索推荐 资源调度
使用VitePress静态网站生成器创建组件库文档网站并部署到GitHub
本文详细介绍了如何使用 Vue3、TypeScript 和 Vite 开发并发布一个名为 Vue Amazing UI 的组件库至 npm。文章首先引导读者安装配置 VitePress,创建文档网站,并编写组件库文档。接着,通过一系列配置实现网站主题定制、全局样式设置以及 Algolia 搜索功能集成。最后,文章提供了自动化脚本,帮助开发者一键打包部署静态网站至 GitHub,并发布组件库到 npm。通过这些步骤,读者可以轻松搭建并维护一个美观且功能齐全的组件库文档网站。
193 2
使用VitePress静态网站生成器创建组件库文档网站并部署到GitHub
|
资源调度 搜索推荐 Shell
使用VitePress静态网站生成器创建组件库文档网站并部署到GitHub
本文介绍了如何使用 Vue3、TypeScript 和 Vite 开发组件库并将其发布到 npm。文章详细描述了安装依赖、配置项目、创建文档网站以及编写组件文档的步骤。通过使用 VitePress,可以轻松搭建组件库的文档站点,并实现 Algolia 搜索功能。此外,还提供了自动化脚本用于部署静态网站至 GitHub 以及发布组件库到 npm。最后,展示了完整的目录结构和网站效果。
531 1
使用VitePress静态网站生成器创建组件库文档网站并部署到GitHub
|
12月前
|
存储 Linux 数据安全/隐私保护
一键部署 200+ 开源Github 2k+ 星星的软件
Websoft9面板是一款基于Web的PaaS/Linux面板,支持在个人服务器上一键部署200多种热门开源应用,适用于个人开发者、中小企业、创业团队、教育机构和技术爱好者。它集成了丰富的开源软件,提供便捷的部署方式、高效的资源利用、良好的可扩展性及低技术门槛,帮助用户快速搭建和管理各类应用。
|
网络协议 开发工具 git
hexo github部署,通过域名访问你的博客
本文介绍了如何使用Hexo命令部署博客到GitHub,并详细说明了如何通过自定义域名访问GitHub上部署的博客。
hexo github部署,通过域名访问你的博客
|
SQL 安全 网络安全
GitHub点赞飙升!电信大牛的Python渗透测试实战指南
在网络安全领域,会不会编程,是区分“脚本小子”和真正黑客的关键。实际的渗透测试中会遇到各种复杂的网络环境,常用工具不一定能满足需求,这时就需要对现有工具进行扩展,或者编写符合要求的工具、自动化脚本,这都需要一定的编程能力。在分秒必争的 CTF 竞赛中,想要高效地使用自制脚本工具来达成各种目的,更是需要有编程能力。 Python 这两年越来越火!除了语法简单、开发效率高以外,Python 最大的优势就是拥有超多第三方库。很多有名的网络安全工具和安全系统框架都是用 Python 开发的!所以,掌握 Python 编程已经成为网络安全从业者的必备技能之一。如果你想成为一名合格的安全从业者,就不能只会
爆赞!GitHub首本Python开发实战背记手册,标星果然百万名不虚传
Python (发音:[ 'paiθ(ə) n; (US) 'paiθɔn ] n. 蟒蛇,巨蛇 ),是一种面向对象的解释性的计算机程序设计语言,也是一种功能强大而完善的通用型语言,已经具有十多年的发展历史,成熟且稳定。Python 具有脚本语言中最丰富和强大的类库,足以支持绝大多数日常应用。 Python 语言的特点:

热门文章

最新文章