常用命令小记

256 阅读1分钟

记录常见的命令

Git

## reflog
git reflog
## 获取某次提交
git cherry-pick <commit-id>
## 删除远程分支
git push origin --delete <branchName>
## 删除本地仓库
git branch -D <branchName>

## 添加远程仓库
git remote add <remoteName>

## 查看所有远程仓库
git remote -v

## 拉取远程分支,建立映射关系
git checkout -b <localBranchName> <remoteName>/<remoteBranchName>
## 拉取远程分支,不建立映射关系
git fetch origin <remoteBranchName>:<localBranchName>

## 设置upstream
git push --set-upstream origin dev-chasexu-release-20220416

## 从某个commit新建分支
git checkout <commitId> -b <localBranchName>

## 推送本地分支到一个新的远程分支
git push <remoteName> <localBranchName>:<remoteBranchName>

## 删除缓存(新添加文件到gitignore中,需要先清除缓存之后再add)
git rm -r --cached .


## stash相关操作
git stash list [<log-options>]
git stash show [<diff-options>] [<stash>]
git stash drop [-q|--quiet] [<stash>]
git stash ( pop | apply ) [--index] [-q|--quiet] [<stash>]
git stash branch <branchname> [<stash>]
git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
	     [-u|--include-untracked] [-a|--all] [-m|--message <message>]
	     [--pathspec-from-file=<file> [--pathspec-file-nul]]
	     [--] [<pathspec>…​]]
git stash clear
git stash create [<message>]
git stash store [-m|--message <message>] [-q|--quiet] <commit>