代码之家  ›  专栏  ›  技术社区  ›  Nick Bull

删除未命名的git分支

  •  0
  • Nick Bull  · 技术社区  · 6 年前

    > 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
    
    1 回复  |  直到 6 年前
        1
  •  1
  •   Romain Valeri    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
    
        2
  •  0
  •   ParagDineshGupta    6 年前

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