Tip:在本地要安装好Git,官网:https://git-scm.com/

如何将本地项目推送到Github

一个学习Git的好地方:https://try.github.io/

在线闯关实战,边练边学的好地方:https://learngitbranching.js.org/

方法一:使用https推送

# 步骤
# 1.创建一个目录
mkdir Test
# 2.将当前目录变为git管理仓库
git init
# 3.将文件添加到版本库,这里将目录下的所有文件都添加进去了
git add .
# 4.告诉git将文件提交到仓库
git commit -m "first-commit"
# 5.将当前仓库与远程仓库关联
git remote add orign 远程仓库的https地址 # eg: git remote add https://github.com/ssmath/Test.git
# 6.将仓库内master分支的所有内容推送到远程仓库,这里会使用到Github的账号密码
git push -u orign master

如何将本地项目推送到Github

如何将本地项目推送到Github

方法二:使用ssh推送

  1. 生成ssh密钥
ssh-keygen -t rsa -C "your email address"
# eg: ssh-keygen -t rsa -C "1329441308@qq.com"

如何将本地项目推送到Github

  1. 找到生成的文件,复制id_rsa.pub文件中的内容,文件一般在用户目录下的.ssh目录中

如何将本地项目推送到Github

  1. 使用密钥与远程仓库配对,检验能否成功通讯

如何将本地项目推送到Github

ssh -T git@github.com  # 检验能否成功通讯

如何将本地项目推送到Github

  1. 推送本地文件到github

如何将本地项目推送到Github

相关文章:

  • 2021-07-28
  • 2021-08-18
  • 2021-12-17
  • 2021-04-05
  • 2021-07-14
  • 2021-06-16
猜你喜欢
  • 2021-12-22
  • 2021-08-24
  • 2021-12-25
  • 2022-12-23
  • 2021-10-20
  • 2021-09-16
  • 2021-04-22
相关资源
相似解决方案