1、初始化本地仓库
打开本地项目,比如说我的项目就叫demo,进入demo文件夹,我以hello.txt代替项目内容,打开git bash,执行如下命令:
git init
git add .
git commit -m '提交项目'
然后打开github,点击右上角:
新建一个远程仓库:
仓库名字和本地仓库一样,这里就是demo,描述随便写
点击下方createRepository就可以创建远程的仓库了,创建成功会跳转到如下界面:
点击复制,然后在git bash中执行如下命令:
git push -u https://github.com/wangyf98/demo.git master
2、报错:
fatal: unable to access 'https://github.com/wangyf98/demo.git/': Failed to connect to github.com port 443: Timed out
3、解决:
执行以下四条命令:
git config --global http.proxy http://127.0.0.1:1080
git config --global https.proxy http://127.0.0.1:1080
git config --global --unset http.proxy
git config --global --unset https.proxy
再次执行推送远程仓库的命令,成功。 刷新GitHub页面,成功,如图: