GitHub作为免费的远程仓库,如果是个人的开源项目,放到GitHub上是完全没有问题的。
git 本地配置
- 配置用户
$ git config --global user.name "brightranger"
- 配置邮箱
$ git config --global user.email "332478519@qq.com"
为Github账户设置SSH key
生成rsa类型的私钥和公钥
$ ssh-keygen -t rsa -C "332478519@qq.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/c/Users/Administrator/.ssh/id_rsa):
/c/Users/Administrator/.ssh/id_rsa already exists.
Overwrite (y/n)?
这样在路径:C:\Users\Administrator.ssh就生成了我们的公钥和私钥文件:
image.png
其中id_rsa.pub为公钥文件。
id_rsa为私钥文件
把公钥文件的内容上传到个人github的对应位置
关联远程仓库
$ git remote add origin git@github.com:brightranger/spring-transation-simple-demo.git
把github的内容下载到本地
强制下载到本地,跟本地合并,目的是为了后面上传的时候没有冲突
$ git pull origin master --allow-unrelated-histories
把本地代码上传到github中
$ git push origin master
Enumerating objects: 58, done.
Counting objects: 100% (58/58), done.
Delta compression using up to 4 threads
Compressing objects: 100% (39/39), done.
Writing objects: 100% (58/58), 15.67 KiB | 802.00 KiB/s, done.
Total 58 (delta 2), reused 0 (delta 0)
remote: Resolving deltas: 100% (2/2), done.
To github.com:brightranger/spring-transation-simple-demo.git
* [new branch] master -> master
网友评论