Skip to content

umranium/git-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

git-tree

Utility for working on GIT tree/chain branches

Usage

To fix a local updated branch structure to reflect the remote branch structure

git_tree update branch-name [branch-name ...]

After updating a local branch

For example:

You have the following branch structure:

master    base-branch      branch-1
|         |                |
c0 <---- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

after pushing this structure to remote, you update base-branch:

                  base-branch      
                  |
master        ,- c5        branch-1
|            /             |
c0 <---- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

At this point, branch-1 and branch-2 will not contain the new changes on base-branch. To rebuild the previous branch structure where branch-1 and branch-2 are based on base-branch and contains all the updated changes run the command:

git_tree update base-branch branch-1 branch-2

End result:

master             base-branch      branch-1
|                  |                |
c0 <---- c1 <---- c5 <---- c2 <---- c3
                      \
                       `- c4
                          |
                          branch-2

After amending a local branch

For example:

You have the same branch structure as above:

master    base-branch      branch-1
|         |                |
c0 <---- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

after pushing this structure to remote, you update base-branch as before but you amend the branch:

          base-branch      
master    |
|     ,-- c5        
|    /             
c0 <-              branch-1
     \             |
      `-- c1 <---- c2 <---- c3
              \
               `- c4
                  |
                  branch-2

At this point, branch-1 and branch-2 (as before) will not contain the new changes on base-branch. To rebuild the previous branch structure where branch-1 and branch-2 are based on base-branch and contains all the updated changes run the command:

git_tree update base-branch branch-1 branch-2

End result:

master   base-branch       branch-1
|        |                 |
c0 <---- c5 <---- c2 <---- c3
                      \
                       `- c4
                          |
                          branch-2

To "rebase" a local branch structure when the remote get's updated

"Rebase" the branch structure with all the branches

git_tree rebase --onto base-branch branch-name [branch-name ...]

For example:

You have the following branch structure (yeah same one again):

master    base-branch      branch-1
|         |                |
c0 <---- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

master gets updated remotely. After pulling the changes, you have the following structure:

         master
         |
     ,-- c5
    /
c0 <-    base-branch       branch-1
    \    |                 |
     `-- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

At this point, remote doesn't have the original branch structure, and neither does local. To get the original structure:

git_tree rebase --onto master base-branch branch-1 branch-2

End result:

         master   base-branch       branch-1
         |        |                 |
c0 <---- c5 <---- c1 <---- c2 <---- c3
                      \
                       `- c4
                          |
                          branch-2

"Rebase" the branch structure without the root branch

git_tree rebase --onto base-branch --wo-root branch-name [branch-name ...]

For example:

You have the following branch structure (yeah same one again):

master    base-branch      branch-1
|         |                |
c0 <---- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

Your PR(s) get accepted, and squash and merge base-branch onto master. After pulling the changes, you have the following structure:

         master
         |
     ,-- c5
    /
c0 <-    base-branch       branch-1
    \    |                 |
     `-- c1 <---- c2 <---- c3
             \
              `- c4
                 |
                 branch-2

At this point, remote doesn't have the original branch structure, and neither does local.

In addition, the changes in c5 are in fact, the changes in base-branch.

You can rebase the whole structure onto master but you don't need to rebase (and shouldn't) base-branch onto master.

To "rebase" branch-1 and branch-2 onto master but leave out base-branch:

git_tree rebase --onto master --wo-root base-branch branch-1 branch-2

End result:

         master             branch-1
         |                  |
c0 <---- c5  <---- c2 <---- c3
              \
               `- c4
                  |
                  branch-2

About

Utility for working on GIT tree/chain branches

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •  

Languages