美文网首页
ubuntu下将文件备份到github

ubuntu下将文件备份到github

作者: ccbirds | 来源:发表于2020-02-27 15:42 被阅读0次

将hexo博客目录备份到github,以防意外删除文件,这样也方便在其他设备上写博客


1. 安装git

$ sudo apt-get install git

2.生成ssh key

使用命令

$ ssh-keygen -t rsa -C “github username”

会生成下面三个文件

id_rsa  id_rsa.pub  known_hosts

3.github setting

登录github,setting,左边有SSH and GPG keys 选项,点new
ssh key。title随便写,key 填写id_rsa.pub文件中的内容。
新建一个仓库用来备份。
测试ssh key是否成功

$ ssh -T git@github.com
Hi ccbirds! You've successfully authenticated, but GitHub does not provide shell access.

4.在需要备份的目录下初始化git

$ git init
Reinitialized existing Git repository in /home/czq/blog/.git/

5.设置git

$ git config user.name “github user name” 
$ git config user.email “github email”
$ git config user.name //查看设置的name
$ git config user.email //查看设置的邮箱
$ git remote add origin https://github.com/ccbirds/hexo.git //github 仓库地址 
在这里插入图片描述

如果显示origin已经存在,删除origin,并重新设置origin

$ git remote rm origin 
$ git remote add origin https://github.com/ccbirds/hexo.git

6.添加文件

$ git add test.txt //指定一个文件
$ git add .    //目录下的所有文件
$ git commit -m "2020-02-27" //备注
$ git push origin master
Username for 'https://github.com': ccbirds //输入用户名
Password for 'https://ccbirds@github.com':  //输入密码,密码不会显示
Writing objects: 100% (3/3), 277 bytes | 277.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To https://github.com/ccbirds/hexo.git
   da79977..341a1a4  master -> master

这样就成功啦

博客网站 :
ccbirds.cn
ccbirds.github.io

相关文章

  • ubuntu下将文件备份到github

    将hexo博客目录备份到github,以防意外删除文件,这样也方便在其他设备上写博客 1. 安装git 2.生成s...

  • Redis集群备份与恢复

    1、将redis集群A下的数据文件备份 2、将备份文件恢复到redis集群B下。 1、备份redis集群A She...

  • Ubuntu 备份与恢复

    详细教程 Ubuntu可以将系统备份为一个tar压缩文件,也能很方便地从该文件恢复系统。 备份 我们的目标是备份/...

  • Ubuntu 16.04配置国内高速apt-get更新源

    Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件...

  • 更改Ubuntu软件镜像源-TUNA (清华大学开源软件镜像站)

    Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件...

  • Ubuntu 镜像地址修改

    Ubuntu 的软件源配置文件是 /etc/apt/sources.list。将系统自带的该文件做个备份,将该文件...

  • Linux定时任务

    练习题 1、每隔2个小时将系统文件/etc/service 文件打包备份到/tmp 下(每次备份按时间生成不同的备...

  • RVN钱包备份还原

    1、备份钱包 点击【文件】- 选择【备份钱包】-备份钱包文件到指定目录- 关闭软件 2、还原钱包 关闭软件,将备份...

  • Ubuntu备份还原系统

    Ubuntu系统本质是个文件系统,所以备份系统时就像是备份文件,使用tar方式就可以备份系统状态 首先,清理下系统...

  • 2018-12-08

    Ubuntu安装 1.原料:Ubuntu系统、U盘(最好备份其中文件) Ubuntu官网下载。 2.制作安装盘 下...

网友评论

      本文标题:ubuntu下将文件备份到github

      本文链接:https://www.haomeiwen.com/subject/ntfxhhtx.html