Git-常用命令整理
Git 全局设置
git config --global user.name "用户名"
git config --global user.email "用户邮箱"
创建新的仓库并提交代码
git clone 仓库地址
cd 仓库目录
git switch -c 新的分支名
touch README.md
git add README.md
git commit -m "本次提交的描述信息"
git push -u origin 新的分支名
推送本地现有文件夹
cd 文件夹目录
git init
git remote add origin 远程仓库地址
git add .
git commit -m "描述信息"
git push -u origin 分支名
origin 的含义
“git remote add origin 远程仓库地址”
origin 是 该远程仓库的别名
其他
#克隆远程仓库的指定分支到本地
git clone -b 远程分支名 远程分支地址
#pull远程仓库的指定分支
git pull origin 远程指定分支
#push代码【仅第一次需要使用 -u 选项,表示将本地分支关联到远程同名分支】
git push -u origin 分支名
git push origin 分支名
更改远程仓库地址
#1.查看当前远程仓库地址
git remote -v
#2.更改远程仓库值
git remote set-url 远程仓库名称[一般是origin] 远程仓库地址
#例如:
git remote set-url origin https://gitee.com/sea-365/sea_2022_2023.git
#3.再次查看远程仓库地址进行验证
git remote -v
#4.推送一些新的更改...