如何使用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
发布了61 篇原创文章 · 获赞 22 · 访问量 4252

猜你喜欢

转载自blog.csdn.net/yiqiushi4748/article/details/103871177