配置GitBash,使用GitHub
前戏:
从官网下载Git
Windows版:https://github.com/git-for-windows/git/releases/download/v2.21.0.windows.1/Git-2.21.0-64-bit.exe
Linux及其它版:https://book.git-scm.com/downloads
在GitHub上申请有账号:用户名+邮箱+密码
在GitHub上创建自己的库:自定义Repository,我取名叫 "MyFirstRepo"
配置ssh公钥
添加ssh**
$ ssh-****** -t rsa -C "[email protected]" // 引号内填邮箱地址
$ ssh -T [email protected]
成功连接GitHub后配置
用户名和邮箱
$ git config --global user.name "Leonardo" // 用户名
$ git config --global user.email "[email protected]" //邮箱
将GitHub上的库克隆到本地
$ cd /D
$ git clone https://github.com/Leonardo/MyFirstRepo.git
cd /D/MyFirstRepo 进入该文件夹后,有俩文件。
添加新源代码文件
需要将你的代码,放到库的对应的文件夹中
然后使用 先CD到你库里面,
$ cd /D/MyFirstRepo
$ git add filename
$ git commit -m "xxx"
$ git push origin master,
最后将你的代码提交就可以了。
$ cd /D/MyFirstRepo
$ ls
若碰到以下问题,如
提交远程报错[rejected] master -> master (fetch first)
先git pull
再git push
同步Web上的数据即可