本文最后更新于273 天前,其中的信息可能已经过时,如有错误请发送邮件到3589035030@qq.com
设置用户名
“`bash
git config –global user.name “root”
“`
设置邮箱
“`bash
git config –global user.email “admin@example.com”
“`
查看所有Git配置:
“`bash
git config –list
“`
查看特定的配置(如用户名):
“`bash
git config user.name
“`
生成SSH公钥:
“`bash
ssh-keygen -t rsa
“`
查看公钥内容:
“`bash
cat ~/.ssh/id_rsa.pub
“`
初始化本地Git仓库:
“`bash
git init
“`
从远程仓库克隆:
“`bash
git clone 远程Git仓库地址
“`
拉取远程仓库的最新代码并合并到本地:
“`bash
git pull 远程项目的git地址
“`
将修改的文件添加到暂存区:
“`bash
git add 文件名
“`
或者添加所有修改:
“`bash
git add .
“`
提交修改并添加注释:
“`bash
git commit -m “注释内容”
“`
连接到远程仓库
“`bash
git remote add origin 远程Git仓库地址
“`
将当前分支重命名为main
“`bash
git branch -M main
“`
将main分支推送到远程仓库
“`bash
git push -uf origin main
“`
删除文件:
“`bash
git rm 文件名
“`
删除文件夹:
“`bash
git rm –r 文件名
“`
推送:
“`bash
git commit -m “注释内容”
“`