git基本命令

2025-04-18

引言

本博文记录一些常用的git命令

本博文仅供本人学习记录用~

下载GitHub仓库

git clone --recursive https://github.com/{仓库名}

重新初始化

rm -rf .git

push到已有仓库并创新新分支

  1. 初始化 Git 仓库(如果尚未初始化)
git init
  1. 添加远程仓库
git remote add origin https://github.com/{仓库名}.git
  1. 创建并切换到新分支(如分支名a100)
git checkout -b a100
  1. 添加并提交更改
git add .
git commit -m "Initial commit on branch a100"
  1. 推送到远程仓库
git push -u origin a100

更改默认分支

如下图所示