欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

【GitHub - Windows 10】上传本地文件夹到GitHub仓库

程序员文章站 2022-04-18 12:49:39
...

0.前言

创建GitHub账户,创建仓库等应该无需我赘述,大家在GitHub的官网即可轻松完成这些操作。

1.安装Git

安装Git的方式有很多种,我才用的是在安装Visual Studio 2019时,使用VS的安装器直接安装了Git和相关的工具。
你也可以在这里下载:

https://git-scm.com/download/win

2.配置

2.1.生成SSH的公钥和**

打开GitBash,输入:

ssh-key -t rsa -C "aaa@qq.com"

两个回车之后就会显示成功,如下:

Generating public/private rsa key pair.
Enter file in which to save the key (C:\Users\44375/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in C:\Users\44375/.ssh/id_rsa.
Your public key has been saved in C:\Users\44375/.ssh/id_rsa.pub.
The key fingerprint is:
................

2.2.将SSH私钥添加到 ssh-agent

1.设置用户名

aaa@qq.com MINGW64 ~
$ git config --global user.name "用户名"

2.设置邮箱

aaa@qq.com MINGW64 ~
$ git config --global user.email "用户邮箱"

3.查看当前配置

aaa@qq.com MINGW64 ~
$ git config --list

4.启动ssh -agent

aaa@qq.com MINGW64 ~
$ eval $(ssh-agent -s)
Agent pid 838

5.添加SSH私钥到ssh -agent

aaa@qq.com MINGW64 ~
$ ssh-add /c/Users/44375/.ssh/id_rsa
Identity added: /c/Users/44375/.ssh/id_rsa (/c/Users/44375/.ssh/id_rsa)

5.复制SSH公钥,准备粘贴到GitHub

aaa@qq.com MINGW64 ~
$ clip < /c/Users/44375/.ssh/id_rsa.pub

6.粘贴到GitHub个人SSH and GPG keys
【GitHub - Windows 10】上传本地文件夹到GitHub仓库
6.测试:

aaa@qq.com MINGW64 ~
$ ssh -T aaa@qq.com
Warning: Permanently added the RSA host key for IP address '13.250.177.223' to the list of known hosts.
Hi QiuMingZS! You've successfully authenticated, but GitHub does not provide shell access.

3.本地仓库上传

3.1.本地仓库初始化

1.移动到本地仓库文件夹下

aaa@qq.com MINGW64 ~
$ cd /c/Users/44375/Desktop/CrossClassify

2.初始化

aaa@qq.com MINGW64 ~/Desktop/CrossClassify
$ git init
Initialized empty Git repository in C:/Users/44375/Desktop/CrossClassify/.git/

3.关联

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ git remote add origin https://github.com/QiuMingZS/Road_Intersection_Classfify

4.查看当前状态

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ 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)
        CrossClassify/

nothing added to commit but untracked files present (use "git add" to track)

5.添加文件

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ git add .

**
6.将修改提交到仓库

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ git commit -m 'original'
[master 5cf049a] original
 5 files changed, 653 insertions(+)
 create mode 100644 CrossClassify/Network.py
 create mode 100644 CrossClassify/datasets_prepare.py
 create mode 100644 CrossClassify/image_pre_process.py
 create mode 100644 CrossClassify/test.py
 create mode 100644 CrossClassify/train.py

7.Push

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ git push origin master
Enumerating objects: 9, done.
Counting objects: 100% (9/9), done.
Delta compression using up to 16 threads
Compressing objects: 100% (8/8), done.
Writing objects: 100% (8/8), 6.66 KiB | 3.33 MiB/s, done.
Total 8 (delta 0), reused 0 (delta 0), pack-reused 0
To https://github.com/QiuMingZS/Road_Intersection_Classfify
   2141477..5cf049a  master -> master

8.Pull

aaa@qq.com MINGW64 ~/Desktop/CrossClassify (master)
$ git pull https://github.com/QiuMingZS/Road_Intersection_Classfify
remote: Enumerating objects: 8, done.
remote: Counting objects: 100% (8/8), done.
remote: Compressing objects: 100% (6/6), done.
remote: Total 6 (delta 1), reused 0 (delta 0), pack-reused 0
Unpacking objects: 100% (6/6), 1.70 KiB | 69.00 KiB/s, done.
From https://github.com/QiuMingZS/Road_Intersection_Classfify
 * branch            HEAD       -> FETCH_HEAD
Updating 5cf049a..9ddf833
Fast-forward
 README.md | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)