本地初始化一个仓库,并且关联到GitHub远程的新建仓库。
配置Git用户和邮箱
配置git全局用户和邮箱,连接GitHub的话要配置成GitHub的用户名和邮箱,但是下边我用的不是GitHub的用户名,也能够用。
- git config --global user.name username
- git config --global user.name email_address
Roc@DESKTOP-AF552U2 MINGW64 /f/mygitpro
$ git config --global user.name RocSun
Roc@DESKTOP-AF552U2 MINGW64 /f/mygitpro
$ git config --global user.email 710989028@qq.com
创建SSH密匙对
推送至GitHub时需要用到SSH密匙对,通过git制作密钥对,Windows下的密钥保存在C:UserUserName.ssh
文件夹下边,一个公钥id_rsa.pub
文件,一个私钥id_rsa
文件。后边的邮箱是GitHub的邮箱,是否需要密码看心情。
- ssh-keygen -t rsa -C '注册GitHub的邮箱'
Roc@DESKTOP-AF552U2 MINGW64 /f/mygitpro (master)
$ ssh-keygen -t rsa -C '710989028@qq.com'
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Roc/.ssh/id_rsa):
Created directory '/c/Users/Roc/.ssh'.
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /c/Users/Roc/.ssh/id_rsa.
Your public key has been saved in /c/Users/Roc/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:s9KZlaSzp3qlmY/u/nEpxOIpRwV04CNY7WFcpIPxUBE 710989028@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| +=E*+ |
| o *=+ |
| . oo*.o |
| ..B . |
| S = |
| + %. . |
| o X=+ o |
| +=+ + |
| .**oo |
+----[SHA256]-----+
ssh创建成功,在GitHub上添加SSH后进行测试。
- ssh -T git@github.com
Roc@DESKTOP-AF552U2 MINGW64 ~
$ ssh -T git@github.com
The authenticity of host 'github.com (13.229.188.59)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,13.229.188.59' (RSA) to the list of known hosts.
Hi RocsSun! You've successfully authenticated, but GitHub does not provide shell access.
初始化仓库
将目标文件夹初始化仓库
- git init
Roc@DESKTOP-AF552U2 MINGW64 /e/note
$ ls
Bug/ Flask/ MySQL/ python安装报错.md Vue/
Django/ Git/ Project/ Redis/ 孙鹏飞.md
Django回顾.md JavaScript/ Python/ 'Virtualenv&wrapper'/
Roc@DESKTOP-AF552U2 MINGW64 /e/note
$ git init
Initialized empty Git repository in E:/note/.git/
添加到仓库,并提交到仓库
将目标文件添加到仓库,并提交到仓库
- git add file
- git commit -m 'message'
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git add ./*
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git commit -m '初始化仓库,提交以前的所有笔记'
[master (root-commit) 53ab25a] 初始化仓库,提交以前的所有笔记
39 files changed, 2260 insertions(+)
create mode 100644 Bug/Windows-0x80070570.md
create mode 100644 "Bug/python345256211350243205346212245351224231.md"
create mode 100644 "Bug/346225260346215256350277201347247273346212245351224231.md"
create mode 100644 Django/Django-module/Django-Admin.md
create mode 100644 Django/Django-module/Django-Form&ModelForm.md
create mode 100644 Django/Django-module/Django-Meta.md
create mode 100644 Django/Django-module/Django-field.py
create mode 100644 Django/Django-module/HTTP.md
create mode 100644 Django/Django-module/MVC.md
create mode 100644 Django/Django-module/MVT.md
create mode 100644 Django/Django-rest-framework/Django-rest-framework-Install.md
create mode 100644 Django/Django-rest-framework/Django-rest-framework-Serializers.md
create mode 100644 Django/Django-rest-framework/Django-rest-framwork-startquickly.md
create mode 100644 "Django345233236351241276.md"
create mode 100644 "Flask/flask347232204345256211350243205345217212345277253351200237350277220350241214.md"
create mode 100644 "Git/git347232204345210235346254241344275277347224250.md"
create mode 100644 "Git/git347232204351200211351241271345217202346225260.md"
create mode 100644 Project/BBS/BBS_database_design.md
create mode 100644 Project/blog/blog_database.md
create mode 100644 Python/meriyouxian.py
create mode 100644 "Redis/Redis347232204344273213347273215.md"
create mode 100644 Virtualenv&wrapper/Virtualenvwrapper.md
create mode 100644 "Virtualenv&wrapper/virtualenv347232204344275277347224250.md"
create mode 100644 Vue/ES6_Class.md
create mode 100644 "Vue/ES6_Deconstruction(350247243346236204).md"
create mode 100644 Vue/ES6_DefineVariable.md
create mode 100644 Vue/ES6_ImportExport.md
create mode 100644 Vue/ES6_TemplateString.md
create mode 100644 "Vue/Vue-347273204345273272.md"
create mode 100644 "Vue/Vue_346214207344273244.md"
create mode 100644 "Vue/Vue345277203345276227.md"
create mode 100644 "Vue/Vue347232204345237272347241200346223215344275234.md"
create mode 100644 Vue/luffy.html
create mode 100644 Vue/routelink.html
create mode 100644 Vue/test.html
create mode 100644 Vue/vue.html
create mode 100644 "Vue/347273204345273272.html"
create mode 100644 "python345256211350243205346212245351224231.md"
create mode 100644 "345255231351271217351243236.md"
关联远程仓库
在GitHub上新建一个空仓库,并使用git关联GitHub的新建仓库。
- git remote add origin git@github.com:GitHubName/RepositoryName.git
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git remote add origin git@github.com:RocsSun/note.git
推送至GitHub仓库
第一次推送要使用-u
选项。
- git push -u origin master
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)
$ git push -u origin master
Enumerating objects: 49, done.
Counting objects: 100% (49/49), done.
Delta compression using up to 4 threads
Compressing objects: 100% (43/43), done.
Writing objects: 100% (49/49), 32.97 KiB | 1.14 MiB/s, done.
Total 49 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
remote:
remote: Create a pull request for 'master' on GitHub by visiting:
remote: https://github.com/RocsSun/note/pull/new/master
remote:
To github.com:RocsSun/note.git
* [new branch] master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.
Roc@DESKTOP-AF552U2 MINGW64 /e/note (master)