将代码上传到 github 上
github相关操作
将代码上传到 github 上
1、生成秘钥并加入到github上
打开电脑终端,输入ssh-keygen -t rsa -C “"youremail@example.com"
,然一路回车,再输入密码
其中 /c/Users/jinlong/.ssh/di_ras 中存储的为秘钥,复制该秘钥
例如:
ssh-rsa AAAAB3NzaC1yc2EAAAADAQ……………………………………RBmGt03uU+n4Osw== jinlong.dai@deepsight.ai
打开github,转到 setting 然后找到 SSH and GPG keys,点击右上角 New SSH key,然后将秘钥粘贴到 Key 中,在 Title 中取个名字
2、上传代码
安装 git ,然后在需要上传代码的文件夹中,单击鼠标右键,点击 Git Bash Here,
依次输入一下命令
初始化本地仓库,命令:git init
设置提交的用户名及邮箱,命令:
git config --global user.name
git config --global user.email
连接GitHub远程仓库,命令:git remote add origin https://github.com/xxxxx/test.git
git remote add origin 你自己的https地址
拉取仓库中的代码,命令:git pull --rebase origin master
添加文件,命令:git add .
这是将文件添加到暂存区命令,但是并没有提交到服务器上
添加提交信息,命令:git commit -m "提交信息"
提交代码,命令:git push -u origin master
执行完后代码已成功提交到github上。
3、下载代码
新建文件夹,单击鼠标右键,点击 Git Bash Here,
然后输入 git init
,初始化文件夹,
然后在输入git clone https://github.com/htdt/hyp_metric.git
,其中 https://github.com/htdt/hyp_metric.git
为你要下载的代码HTTPS
4、更新git代码
先输入 git add .
这是将文件添加到暂存区命令
添加提交信息,命令:git commit -m "提交信息"
提交代码,命令:git push -u origin master
执行完后代码已成功提交到github上。
更多推荐
所有评论(0)