[Git] 常用操作速查

记录了本人在科研中常用到的git操作,方便查询,内容并不全面,更多功能等用到的时候再加

基础操作:

初始化仓库

git init

克隆仓库/克隆仓库的指定分支

git clone <URL>
git clone -b branch_name <URL>

添加、提交全部修改

git add .
git commit -m "message"

分支操作

显示当前branch
git branch

本地分支重命名
git branch -m oldname newname

显示本地和远程所有branch
git branch -a

创建并切换新分支
git checkout -b branch_name
等价于:
git checkout branch_name
git branch branch_name

删除本地分支
git branch -d branch_name

删除远程分支
git push --delete remote_name branch_name

Remote操作

git remote [-v | --verbose]  显示所有remote,-v显示remote更多信息
git remote add [-t <branch>] [-m <master>] [-f] [--[no-]tags] [--mirror=<fetch|push>] <name> <url>
git remote rename <old> <new>
git remote remove <name>
git remote set-head <name> (-a | --auto | -d | --delete | <branch>)
git remote set-branches [--add] <name> <branch>…​
git remote get-url [--push] [--all] <name>
git remote set-url [--push] <name> <newurl> [<oldurl>]
git remote set-url --add [--push] <name> <newurl>
git remote set-url --delete [--push] <name> <url>
git remote [-v | --verbose] show [-n] <name>…​
git remote prune [-n | --dry-run] <name>…​
git remote [-v | --verbose] update [-p | --prune] [(<group> | <remote>)…​]
原文地址:https://www.cnblogs.com/geoli/p/13304862.html