文章目录
1 注册GitHub账号
GitHub
官网:https://github.com/
注册流程没有什么难点,自行完成即可~
2 创建仓库
点击Repositories旁边的New按钮
填写仓库信息
创建成功后,把浏览器中的地址复制出来,比如我的是:https://github.com/linxinfa/myTest
3 克隆仓库到本地
这步需要用到github客户端,下载地址:https://desktop.github.com/
打开GitHub
客户端,点击菜单:File / Clone repositor...
填下远程仓库的地址,填写本地目录位置,点击
Clone
按钮成功
Clone
到本地打开本地目录
4 新增文件并提交
在本地新增文件,比如NewFile.txt
然后打开
GitHub
客户端,填写提交日志,点击提交按钮也可以用git
命令行提交,命令行工具下载地址:https://gitforwindows.org/
在本地目录空白处右键,点击Git Bash Here
上面使用
GitHub
客户端的克隆仓库的操作,使用命令行会更方便,对应的命令为:
git clone https://github.com/linxinfa/myTest
添加文件和提交命令
git add NewFile.txt
git commit -m "add NewFile"
5 把提交内容推到GitHub仓库
使用git命令行工具,输入命令:git push -u origin master
中间可能需要输入账号密码
即可把把提交内容推到GitHub
仓库
回到网页端刷新一下,即可看到我们提交的内容了
6 删除仓库
网页端进入仓库页面,点击Settings
拉到最下面,点击
Delete this repository
即可删除仓库7 常用的git指令
git init #把当前目录变成git可以管理的仓库
git add readme.txt #添加一个文件,也可以添加文件夹
git add -A #添加全部文件
git rm test.txt #删除一个文件,也可以删除文件夹
git commit -a -m "some commit" #提交修改
git status #查看是否还有未提交
git log #查看最近日志
git reset --hard HEAD^ #版本回退一个版本
git reset --hard HEAD^^ #版本回退两个版本
git reset --hard HEAD~100 #版本回退多个版本
git remote add origin +地址 #远程仓库的提交(第一次链接)
git push -u origin master #仓库关联
git push #远程仓库的提交(第二次及之后)
8 如何在README.md中显示图片
格式
![](https://xxxxxxxxxxxx.png)
可以先把图片上传到GitHub
工程中,然后点击Download
,即可得到图片的https
链接
9 GitHub上传图片裂开无法显示的问题
上传图片到GitHub中,图片是裂的,无法显示,以为是图片上传时转码的问题,但其实是浏览器dns
配置的问题。
修改C:\Windows\System32\drivers\etc
里的hosts
文件,在最后添加如下的映射即可
# GitHub Start
140.82.113.3 github.com
140.82.114.20 gist.github.com
151.101.184.133 assets-cdn.github.com
151.101.184.133 raw.githubusercontent.com
151.101.184.133 gist.githubusercontent.com
151.101.184.133 cloud.githubusercontent.com
151.101.184.133 camo.githubusercontent.com
151.101.184.133 avatars0.githubusercontent.com
199.232.68.133 avatars0.githubusercontent.com
199.232.28.133 avatars1.githubusercontent.com
151.101.184.133 avatars1.githubusercontent.com
151.101.184.133 avatars2.githubusercontent.com
199.232.28.133 avatars2.githubusercontent.com
151.101.184.133 avatars3.githubusercontent.com
199.232.68.133 avatars3.githubusercontent.com
151.101.184.133 avatars4.githubusercontent.com
199.232.68.133 avatars4.githubusercontent.com
151.101.184.133 avatars5.githubusercontent.com
199.232.68.133 avatars5.githubusercontent.com
151.101.184.133 avatars6.githubusercontent.com
199.232.68.133 avatars6.githubusercontent.com
151.101.184.133 avatars7.githubusercontent.com
199.232.68.133 avatars7.githubusercontent.com
151.101.184.133 avatars8.githubusercontent.com
199.232.68.133 avatars8.githubusercontent.com
# GitHub End
10 repositories与projects区别
1 repositories
翻译为代码仓库,可以保存多个代码工程和项目的代码,资源,文本、图片等
2 projects
可以翻译为项目板,是project-boards
的简写。简单说,可以理解为工作计划表之类的书签,制定一下工作计划,Bug
,流程什么的
11 搜索技巧
in:name 爬虫 //搜索名字中带有"爬虫"的
in:readme 爬虫 //搜索readme中带有"爬虫"的
in:description 爬虫 //搜索描述中带有"爬虫"的
stars:>1000 //搜索stars>1000的
forks:>1000 //搜索forks>1000的
pushed:>2019-09-01 //搜索最近更新于2019年9月1日之后的
language:Python //搜索Python的项目
12 LF与CRLF
在Windows
系统中,使用git add
命令的时候,可能会提示如下的warning
警告:LF will be replaced by CRLF
CRLF
和LF
是文本换行的不同方式:CRLF
: \r\n
,Windows
系统的换行方式LF
: \n
,Linux
系统的换行方式
他们之间的不同经常会导致不同会导致使用不同系统的同事之间的代码冲突问题。
在你使用 git
添加或拉取代码的时候,git
会自动将代码当中与你当前系统不同的换行方式转化成你当前系统的换行方式,从而造成这种冲突。
Windows
系统解决办法:
修改 git
全局配置,禁止git
自动将 LF
转换成 CRLF
,命令:
git config --global core.autocrlf false
原文地址:https://linxinfa.blog.csdn.net
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。