指令 | 解释 | 链接 |
---|---|---|
git branch | 用于查看本地有多少个分支 | |
git branch -a | 用于查看本地分支与远程分支 | |
git branch -vv | 用于查看本地分支与远程分支的对应 | |
git branch myBranch | 创建本地myBranch分支 | |
git branch -d myBranch | 删除本地myBranch分支 | |
git branch -m oldBranchName newBranchName | 将本地分支oldBranchName重命名为newBranchName | |
git checkout anyBranch | 切换到anyBranch | |
git checkout - - . | 将本地缓存区中的修改文件恢复到没修改之前 | |
git rm --cached anyFile | 删除已add的文件 | |
git commit --amend | 追加到上一次提交 | |
git reset --hard HEAD^ | 撤销上一次的提交 | https://www.jianshu.com/p/c2ec5f06cf1a |
git remote | 能看到远程仓别名(origin) | |
git remote -v | 能看到远程仓对应的真实地址 | |
git pull | git fresh + git merge | |
git fresh | 将远程仓的代码同步到本地 | |
git pull -r | git fresh + git rebase | |
git rebase master(目标MR) | 根据master当前版本,为本地分支重新建立基点。有效的避免合入时冲突,有冲突能在本地解决 | |
git cherry-pick commitHash | 可以把其他分支的某个commit合并到当前分支,当前分支会多一个commit | https://blog.csdn.net/qq_35432904/article/details/107232691 |
git branch --set-upstream-to=origin/remote_branch your_branch | 本地分支关联远程分支 | |
git apply patch | 合入path | |