准备工作
- 已经绑定了SSH的Github账号,如果没有可以参考这篇文章
- cmd
- Github项目
克隆
- 点开你的github项目,点击下载,并选择Clone with SSH
其中,红色框框圈出的是github用户名,黄色框框圈出的是项目名称。顺便说下,这个LearnPython是一个很好的通过写小型项目学习python的教程,有兴趣的朋友可以去看看。以撸代码的形式学习Python
将git@github.com:RonnieShane99/LearnPython.git
复制下来。
- 打开cmd
#这里选择将项目下载到C:\Users\ronni\Downloads>
#进入downloads文件夹
cd downloads
#下载刚刚选定的项目
git clone git@github.com:RonnieShane99/LearnPython.git
#会出现以下结果
Cloning into 'LearnPython'...
remote: Enumerating objects: 350, done.
remote: Total 350 (delta 0), reused 0 (delta 0), pack-reused 350
Receiving objects: 100% (350/350), 912.71 KiB | 359.00 KiB/s, done.
Resolving deltas: 100% (175/175), done.
#进入项目的文件夹
cd LearnPython
#显示文件夹中的文件
dir
#结果显示
驱动器 C 中的卷是 OS
卷的序列号是 B49A-8F19
C:\Users\ronni\Downloads\LearnPython 的目录
2020/08/03 19:41 <DIR> .
2020/08/03 19:41 <DIR> ..
2020/08/03 19:41 179 .gitignore
2020/08/03 19:41 <DIR> Docker
2020/08/03 19:41 <DIR> MyShow
2020/08/03 19:41 3,888 python_aiohttp.py
2020/08/03 19:41 75,527 python_base.py
2020/08/03 19:41 1,938 python_context.py
2020/08/03 19:41 3,323 python_coroutine.py
2020/08/03 19:41 1,178 python_csv.py
2020/08/03 19:41 2,867 python_datetime.py
2020/08/03 19:41 4,850 python_decorator.py
2020/08/03 19:41 6,932 python_flask.py
2020/08/03 19:41 1,780 python_functional.py
2020/08/03 19:41 28,990 python_lda.py
2020/08/03 19:41 1,659 python_magic_methods.py
2020/08/03 19:41 828 python_markov_chain.py
2020/08/03 19:41 1,253 python_metaclass.py
2020/08/03 19:41 3,659 python_oneline.py
2020/08/03 19:41 13,939 python_requests.py
2020/08/03 19:41 6,126 python_restful_api.py
2020/08/03 19:41 3,914 python_spider.py
2020/08/03 19:41 9,443 python_sqlalchemy.py
2020/08/03 19:41 3,543 python_thread_multiprocess.py
2020/08/03 19:41 1,232 python_version36.py
2020/08/03 19:41 13,386 python_visual.py
2020/08/03 19:41 16,940 python_wechat.py
2020/08/03 19:41 5,554 python_weibo.py
2020/08/03 19:41 2,449 README.md
2020/08/03 19:41 <DIR> Text
25 个文件 215,377 字节
5 个目录 3,398,037,504 可用字节
可以看到已经成功下载好了。
上传
#新建两个test.txt
notepad test.txt
git add test.txt
notepad add test2.txt
git add test2.txt
#验证一下
git status
#可以看到输出的结果
On branch master
Your branch is up to date with 'origin/master'.
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
new file: test.txt
new file: test2.txt
上传之前需要输入自己的Github用户名和邮箱
git config --global user.email "you@example.com"
git config --global user.name "Your Name"
接下来
#向Github告知项目的变化
git commit -m "write message here"
#能看到
[master 5cbdabc] write message here
2 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 test.txt
create mode 100644 test2.txt
#将代码上传到Github
git push
#结果
Enumerating objects: 4, done.
Counting objects: 100% (4/4), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 284 bytes | 284.00 KiB/s, done.
Total 3 (delta 1), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (1/1), completed with 1 local object.
To github.com:RonnieShane99/LearnPython.git
491e324..5cbdabc master -> master
这时候,能够很清楚地看到结果
大功告成。