虚拟机使用git进行推送

1.在虚拟机上下载Git

git官网下载:
git官网

2.在虚拟机上配置Git

远程连接进入命令行界面

(1)设置用户名和设置用户账号(需要是自己的注册Github账号)

git config --global user.name "user_name"#(自己的用户名)
git config --global user.email "[email protected]"#(自己Github账号邮箱)

(2)生成密钥对,这样项目可以push到github上

ssh-keygen -t rsa

查看密钥对

 cat ~/.ssh/id_rsa.pub

在github上绑定SSH密钥

3.使用github命令进行提交

#到对应的文件夹下,鼠标右键打开Git的命令窗口
#1.先初始化
git init
#2.添加所有文件至暂存区
git add .
#3.提交本地仓库
git commit -m "first commit"
#4.设置分支
git branch -M main
#5.本地仓库和远程仓库建立连接
git remote add origin https://github.com/xxxx
#6.提交远程仓库
git push -u origin main

虚拟机使用git进行推送_第1张图片

你可能感兴趣的:(git)