github , ubuntu 虚拟机 push file config git --version配置 git 用户名和邮箱git config --global user.name github 用户名git config --global user.email github 邮箱地址git config --global --list 查看配置是否成功生成SSH密钥 用于免密码 PUSH ssh-keygen -t rsa -b 4096 -C github邮箱地址查看公钥 cat ~/.ssh/id_rsa.pub 复制粘贴公钥到 github 网页后台。github 网页 Settings - SSH and GPG keys - New SSH key - Add SSH key 粘贴公钥测试连通 ssh -T gitgithub.com 出现 Youve successfully authenticated 成功进入项目文件夹执行 git init 和 git branch -m maingithub 网页 创建仓库确认远程地址是SSH格式 git remote -v如果远程地址不是SSH格式添加远程仓库地址SSH 格式git remote add origin gitgithub.com:github用户名/仓库.gitgit add .git commit -m 代码改动简要说明首次提交 git push -u origin main 后续提交直接 git push