We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
这次整理 git 分支学到的几个命令
git branch 查看分支情况
git branch
git branch -r 查看远程分支情况
git branch -r
git branch -r --merged 查看已经merged的分支
git branch -r --merged
git branch -D 删除分支
git branch -D
git push origin --delete xxxx 删除远程分支
git push origin --delete xxxx
git branch -r --sort=-committerdate 按最近提交倒序排
git branch -r --sort=-committerdate
git remote prune origin 远程分支没了,但是本地还有,可以用此命令
git remote prune origin
grep -v 排除
grep -v
sed 's/origin\///g' 字符串替换 origin 为 空,其中 s 代表替换
sed 's/origin\///g'
> ~/branch.txt 输出到文件
> ~/branch.txt
xargs 将标准输入数据转换成命令行
xargs
删除本地分支,
// 排除 master 和 feature-dev git branch | grep -v master | grep -v feature-dev | xargs git branch -D
删除远程分支
// 先按最近提交倒序排,并输入到文件 git brnach -r --sort=committerdate > ~/branch.txt // 保险起见,人工做二次检查 open ~/branch.txt // 把分支开头的 origin/ 替换成空字符串,然后输出给 xargs ,进而删除分支操作 cat ~/branch.txt | sed 's/origin\///g' | xargs git push origin --delete
远程分支改了,同步到本地
git fetch -p
The text was updated successfully, but these errors were encountered:
No branches or pull requests
这次整理 git 分支学到的几个命令
git branch
查看分支情况git branch -r
查看远程分支情况git branch -r --merged
查看已经merged的分支git branch -D
删除分支git push origin --delete xxxx
删除远程分支git branch -r --sort=-committerdate
按最近提交倒序排git remote prune origin
远程分支没了,但是本地还有,可以用此命令grep -v
排除sed 's/origin\///g'
字符串替换 origin 为 空,其中 s 代表替换> ~/branch.txt
输出到文件xargs
将标准输入数据转换成命令行实际使用
删除本地分支,
删除远程分支
远程分支改了,同步到本地
The text was updated successfully, but these errors were encountered: