具体步骤参考该文
做一些细节的补充:
在设置ssh-key时,命令为
$ ssh-keygen -t rsa -C "邮箱名"
然后会出现确认信息
Enter file in which to save the key (~/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
这几个地方直接按回车即可,会使用默认值
然后在~/.ssh文件夹下会生成id_rsa.pub
后面在gitee的个人设置里设ssh key
进入你想上传代码文件的文件夹,比如是~/project
比如我想上传train.py文件(如果整个文件夹上传,把train.py换成 . )
$ cd ~/project
$ git init
$ git add train.py
在gitee下载按钮中获得ssh地址,记住不是https开头的
$ git remote add origin git@你的地址
$ git push --set-upstream origin master
$ git commit -m "upload"
$ git push origin
remove origin时用如下命令
git remote rm origin