代码之家  ›  专栏  ›  技术社区  ›  Mostafa Shahverdy

git:合并分支日志

  •  0
  • Mostafa Shahverdy  · 技术社区  · 11 年前

    如何合并git项目的历史记录,使所有提交历史记录都被视为一个分支的一部分?

    目前我有这个:

    * 465a83a Highlight search
    * 37a367d Tab=3; AutosaveSession (Not using yet)
    *   9f2559c Merge branch 'master' of github.com:shahverdy/.vim
    |\  
    | * 6bf7783 SaveSession was added.
    | |\  
    | | * 6cdd383 Some changes with path allocation
    | | |\  
    | | | * de535b2 Update README.md
    | | | * cb78dae Update README.md
    | | | * 6664428 Update README.md
    | | | * b6f3869 Some extra modifications + README.ms
    | | | * 0924e77 Oops! vimrc was not included in the last commit
    | | | * c030172 sweeping away ...
    | | | * d67280e bundle installer was added, some extaras was sweeped away
    | | | * 10a669c Cursors fixed...
    | | | * 9dfd01f Cursors was edited ...
    | | | * 0b5d8aa Syntax for PHP and Javascript was added
    | | | * dd5a21d A bug fixed
    | | | * ad5b9f2 Syntax for PHP and Javascript was added
    | | | * 99e5595 Fixed code folding+ search highlighting
    | | | * 69c7f77 File Explorer fixed
    | | | * ba5fbf7 .vimrc was added
    | | * f875ee1 A totel reset
    | * 9edf692 Update
    * 9c71074 new plugins
    

    我想要这个:

    * 465a83a Highlight search
    * 37a367d Tab=3; AutosaveSession (Not using yet)
    * 9f2559c Merge branch 'master' of github.com:shahverdy/.vim
    * 6bf7783 SaveSession was added.
    * 6cdd383 Some changes with path allocation
    * de535b2 Update README.md
    * cb78dae Update README.md
    * 6664428 Update README.md
    * b6f3869 Some extra modifications + README.ms
    * 0924e77 Oops! vimrc was not included in the last commit
    * c030172 sweeping away ...
    * d67280e bundle installer was added, some extaras was sweeped away
    * 10a669c Cursors fixed...
    * 9dfd01f Cursors was edited ...
    * 0b5d8aa Syntax for PHP and Javascript was added
    * dd5a21d A bug fixed
    * ad5b9f2 Syntax for PHP and Javascript was added
    * 99e5595 Fixed code folding+ search highlighting
    * 69c7f77 File Explorer fixed
    * ba5fbf7 .vimrc was added
    * f875ee1 A totel reset
    * 9edf692 Update
    * 9c71074 new plugins
    

    编辑

    我试过了 git rebase ,输出为 Current branch master is up to date. ,并且静止的历史像以前一样显示。

    谢谢

    1 回复  |  直到 11 年前
        1
  •  1
  •   GoZoner    11 年前

    使用 git rebase --interactive 9c71074 -默认情况下,合并提交是 squashed 。下面是一个例子。

    ebg@ebg(390)$ git log --graph --oneline --all
    *   67fc064 Merge branch 'br-b'
    |\  
    | *   ae81ba0 Merge branch 'br-c' into br-b
    | |\  
    | | * 7fc3f2c c2
    | | * ee878fc c1
    | | * 08bbe31 c
    | * | 7112b66 b2
    | |/  
    | * fb2bb16 b
    * | a4c6fb7 a2
    |/  
    * e2f832e a
    ebg@ebg(391)$ git rebase --interactive e2f832e
    Successfully rebased and updated refs/heads/master.
    ebg@ebg(392)$ git log --graph --oneline --all
    * 1123db2 c2
    * 47b327e c1
    * 8136393 c
    * 4276b1f b2
    * 1020ffa b
    * a4c6fb7 a2
    | *   ae81ba0 Merge branch 'br-c' into br-b   # NOT ON MASTER
    | |\  
    | | * 7fc3f2c c2
    | | * ee878fc c1
    | | * 08bbe31 c
    | * | 7112b66 b2
    | |/  
    | * fb2bb16 b
    |/  
    * e2f832e a
    ebg@ebg(393)$ git log --graph --oneline       # ONLY MASTER
    * 1123db2 c2
    * 47b327e c1
    * 8136393 c
    * 4276b1f b2
    * 1020ffa b
    * a4c6fb7 a2
    * e2f832e a