安装Git,设置账号信息
sudo apt update sudo apt install git git --version git config --global user.name "Your Name" git config --global user.email "your.email@example.com"
生成git密钥
ls -al ~/.ssh ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
测试SSH连接
ssh -T git@github.com #4 返回信息 Hi username! You've successfully authenticated, but GitHub does not provide shell access.
提交项目
git init git add . git commit -m "提交"
推送项目
git remote -v //检查当前远程仓库 URL git remote add origin git@github.com/xxxxxxx //添加一个新的远程仓库地址 git remote set-url origin git@github.com/xxxxxxx //修改远程仓库为 SSH URL git push -u origin master
拉取项目
//查看分支 git branch -r //拉取master 分支代码 git pull origin master //切换main分支 git checkout main //拉取main分支代码 git pull origin main



