如何使用Git上传文件至Github及更新

上传文件至Github

首先在github上创建项目(前提有github账号)

在这里插入图片描述

得到项目地址

在这里插入图片描述

上传步骤

git init
git add README.md
git commit -m "first commit"
git remote add origin https://github.com/SaltNego/Learn_linux_bash.git
git push -u origin master

上传示例

D:\SDPC\学习笔记\Linuxbash
$ git init
Initialized empty Git repository in D:/SDPC/学习笔记/Linuxbash/.git/

D:\SDPC\学习笔记\Linuxbash (master)
$ git add *
warning: LF will be replaced by CRLF in 1.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in add_minus.sh.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in bash_scripts/useradd_while02.sh.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in bash_scripts/useradd_while03.sh.
The file will have its original line endings in your working directory.
warning: LF will be replaced by CRLF in bash_scripts/useradd_while04.sh.
......

D:\SDPC\学习笔记\Linuxbash (master)
$ git commit -m "1st"
[master (root-commit) 1d2a825] 1st
 63 files changed, 1163 insertions(+)
 create mode 100644 1
 create mode 100644 add_minus.sh
 create mode 100644 bash_scripts/useradd_while02.sh
 create mode 100644 bash_scripts/useradd_while03.sh
 create mode 100644 bash_scripts/useradd_while04.sh
 create mode 100644 bash_scripts/users.txt
 create mode 100644 c_for01.sh
 create mode 100644 c_for02.sh
 create mode 100644 c_for03.sh
 create mode 100644 c_for05.sh
 create mode 100644 calllib01.sh
......

D:\SDPC\学习笔记\Linuxbash (master)
$ git remote add origin https://github.com/SaltNego/Learn_linux_bash.git

D:\SDPC\学习笔记\Linuxbash (master)
$ git push -u origin master
fatal: HttpRequestException encountered.
   发送请求时出错。
Counting objects: 65, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (57/57), done.
Writing objects: 100% (65/65), 11.69 KiB | 520.00 KiB/s, done.
Total 65 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To https://github.com/SaltNego/Learn_linux_bash.git
 * [new branch]      master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

D:\SDPC\学习笔记\Linuxbash (master)
$

成功上传

在这里插入图片描述

更新文件至Github

同步步骤

git add *
git commit -m "test"(引号内为说明)
git push origin master

同步示例

D:\SDPC\学习笔记\Linuxbash (master)
$ git add *
warning: LF will be replaced by CRLF in func.md.
The file will have its original line endings in your working directory.

D:\SDPC\学习笔记\Linuxbash (master)
$ git commit -m "3rd"
[master 711961a] 3rd
 1 file changed, 177 insertions(+)
 create mode 100644 func.md

D:\SDPC\学习笔记\Linuxbash (master)
$ git push origin master
fatal: HttpRequestException encountered.
   发送请求时出错。
Counting objects: 3, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 1.26 KiB | 646.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0)
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To https://github.com/SaltNego/Learn_linux_bash.git
   71dda6c..711961a  master -> master
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值