see:https://git-scm.com/
1 常用流程
git init --initial-branch=main # 初始化git仓库
git remote add origin <remote_git_address> # 添加远程分支地址
git pull origin <remote_branch>:<local_branch> # 将远程主机 origin 的 remote_branch 分支拉取过来,与本地的 local_branch 分支合并。
git add -A # 将全部新文件添加至暂存区
git commit -m 'message' # 提交暂存区文件
git push origin <local_branch> # 将本地的 local_branch 分支推送到 origin 主机的 local_branch 分支
2 基本命令
2.1 git init
git init # Initialized empty Git repository in current directory, default branch name is 'master'
git init --initial-branch=<branch_name> # Initialized empty Git repository in current directory, default branch name is 'branch_name'
3 常用命令
3.1 拉取所有远程分支到本地
git clone <git_address>
git branch -r | grep -v '\->' | while read remote; do git branch --track "${remote#origin/}" "$remote"; done
git fetch --all
git pull --all
3.2 刷新远程分支
git remote update origin --prune
3.2 仓库备份和恢复
git clone --bare <old_remote_url>
cd <folder>
git push --mirror <new_remote_url>
3.3 删除tag
git tag -d <tag名称> # 删除本地tag
git push origin --delete <tag_name> # 删除远程tag