社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Git

删除未命名的git分支

Nick Bull • 6 年前 • 2267 次点击  

> git log --graph --oneline --all

* a72aed6 (master) feat(data:model:user): modified db service
* 099becd feat(data:model:user): added CRUD for user model
* 59ac87d refactor(): separating concerns
* dfb983f chore(data:api): removed graphql testing cruft
* aa92817 feat(data:db): setup pg pool connection and query in db/index.ts
* ee03d48 feat(wf): added express
* 184cef0 feat(data:db): added pg
| * 32aedba chore(data:api): removed graphql testing cruft
| * a6825d2 feat(data:db): setup pg pool connection and query in db/index.ts
| * 4a901b1 feat(wf): added express
| * e5753c5 feat(data:db): added pg
|/
* 94426bc (HEAD) feat(qc:test:jest): added test coverage script
* 6126689 feat(build:deploy): added webpack typescript integrations
* 172da85 feat(build:deploy): added webpack-cli
* bab6afa feat(qc): added husky
* c570f33 feat(vcs): added git

我什么都试过了( reset --hard , cherry-pick rebase -i, drop 等)删除提交 e5753c5 到 32aedba

我可以执行什么命令来实现以下输出:

> git log --graph --oneline --all

* a72aed6 (master) feat(data:model:user): modified db service
* 099becd feat(data:model:user): added CRUD for user model
* 59ac87d refactor(): separating concerns
* dfb983f chore(data:api): removed graphql testing cruft
* aa92817 feat(data:db): setup pg pool connection and query in db/index.ts
* ee03d48 feat(wf): added express
* 184cef0 feat(data:db): added pg
* 94426bc feat(qc:test:jest): added test coverage script
* 6126689 feat(build:deploy): added webpack typescript integrations
* 172da85 feat(build:deploy): added webpack-cli
* bab6afa feat(qc): added husky
* c570f33 feat(vcs): added git

git checkout 32aedba
git rebase -i 94426bc
# `drop` to the above commits

git log --graph --oneline --all
# Returns as above, with HEAD at 94426bc
git checkout 32aedba
git reset --hard HEAD~4
# `drop` to the above commits

git log --graph --oneline --all
# Returns as above, with HEAD at 94426bc
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/55252
文章 [ 2 ]  |  最新文章 6 年前
ParagDineshGupta
Reply   •   1 楼
ParagDineshGupta    6 年前

git push origin——删除[branchName] 删除远程分支

RomainValeri
Reply   •   2 楼
RomainValeri    6 年前

首先,一个陈旧的分支不会造成伤害,所以我不清楚你的目标。只是介绍吗?如果是,则只能输出 master 具有

git log --graph --oneline master

但让我们接受一个前提:如何消除不必要的犯罪行为?

你必须找到提交的引用 32aedba 有点像

git branch --contains 32aedba

然后用删除这些分支

git branch -D <branch>

( -D -d 因为它将不合并,需要武力)

另一种方法(参见Lasse的注释)是在命令中输出refs

git log --graph --oneline --all --decorate