例如,我想把Scraping这个新建的项目同步到github上
第一步 : 在自己的GitHub上建立同名目录
第二步: ubuntu中进入目标项目或者新建项目
cdd@ubuntu:~/Desktop$ cd Scraping/
第三步: 创建文件README
cdd@ubuntu:~/Desktop/Scraping$ echo "# Scraping" >> README.md
第四步: 初始化git init
cdd@ubuntu:~/Desktop/Scraping$ git init
第五步: 提交文件
cdd@ubuntu:~/Desktop/Scraping$ git add README.md
第六步: 创建commit
cdd@ubuntu:~/Desktop/Scraping$ git commit -m "first commit"
[master (根提交) ffb89d7] first commit
2 files changed, 1 insertion(+)
create mode 100644 README.md
create mode 100644 first_python.py
第七步: 登录账号
cdd@ubuntu:~/Desktop/Scraping$ git branch -M master
cdd@ubuntu:~/Desktop/Scraping$ git remote add origin https://github.com/Jason-cdd/Scraping.git
cdd@ubuntu:~/Desktop/Scraping$ git push -u origin master
这里需要将github目录的链接输入进来,这个链接在github上新建目录时同步生成的,输入账号和密码后就成功了
Username for 'https://github.com': Jason-cdd
Password for 'https://Jason-cdd@github.com':
枚举对象: 4, 完成.
对象计数中: 100% (4/4), 完成.
使用 4 个线程进行压缩
压缩对象中: 100% (2/2), 完成.
写入对象中: 100% (4/4), 269 字节 | 134.00 KiB/s, 完成.
总共 4 (差异 0),复用 0 (差异 0)
To https://github.com/Jason-cdd/Scraping.git
* [new branch] master -> master
分支 'master' 设置为跟踪来自 'origin' 的远程分支 'master'。