Skip to content

joshMANUmartin/CS471-Assignments-GitReview

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 

Repository files navigation

Exercise: Git Review

Step 1

Familiarize yourself with the repository by checking the repository history, file structure, file contents, etc.

Step 2

Read and understand the contents of the ./chaos_monkey.sh script which will create an intricate repository structure with different branches, but without creating any merge commits.

Each branch will make changes in a separate file, thus avoiding any merge conflicts during future rebasing/merging operations.

The diagram below illustrates the conceptual structure of the repository and emphasizes the chronological order in which the commits were added to the multiple branches. NOTE: The structure of this repository is a simplified version (e.g., it does not contain merge commits and has fewer branches) of the repository from the assignment ch3.3_branch_management.

                                                                                                    (branch6)
                                                                                                        |
             (branch1)                                          (branch4)                  /---------- C18 --------
                 |                                                  |                     /
        /------- C3 ----                     /-------------------- C12 ----------------- C16 -- C17 ---------------
       /                                    /
C0 -- C1 -- C2 --------------------------- C8 -------------- C11 ------------------------------------------- C19 --  //master
             \
              \----- C4 ------ C6 ------------- C9 ------------------- C13
                     |          \                                          \
                 (branch2)       \-- C7 -------------                       \ ---- C15 ----------------------------
                                     |                                              |
                                 (branch3)                                      (branch5)

Step 3

Run the ./chaos_monkey.sh script.

Step 4

Run the following command to view the branch and commit history of the repository, where the current checked out branch is master:

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

Compare the output with the diagram from Step 2.

To focus only on a subset of branches, run:

$ git log --oneline --decorate --graph branch1 branch4 branch6
$ git log --oneline --decorate --graph branch2 branch3 branch5

Compare the output with the diagram from Step 2.

Step 5

Rebase branch3 on top of branch2.

First, checkout the branch that is going to be rebased.

$ git checkout branch3

Second, "zoom" into the two branches to understand better their relationship and interaction.

$ git log --oneline --decorate --graph branch3 branch2

Third, run the following command to conclude the rebasing.

$ git rebase branch2

Next, analyze the result of the rebasing operation.

$ git log --oneline --decorate --graph branch3 branch2
$ git log --oneline --decorate --graph --all

Finally, the branch2 can be safely deleted because it is already integrated into branch3:

$ git branch --merged branch3
$ git branch -d branch2

Step 6

Rebase branch5 on top of branch3.

Delete branch3.

Step 7

Rebase branch6 on top of branch4.

Delete branch4.

Step 8

Rebase branch6 on top of master.

At this point, branch6 is "ahead" of master by four commits. To integrate the changes from branch6 back into master use the merge command, which will result in a "fast forward" merge since:

  • master did not diverge from branch6 and
  • branch6 had its commits "(re)based" on master (which was the result of the previous rebasing).
$ git checkout master
$ git merge branch6
$ git log --oneline --decorate --graph --all

Delete branch6.

Step 9

Rebase branch1 on top of master.

Merge into master the changes from branch1, using the "fast forward" strategy.

Delete branch1.

Step 10

Finally, rebase branch5 on top of master, then ("fast forward") merge the changes from branch5 back into master, and delete branch5.

Step 11

Run the following command:

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

It is important to highlight that after these rebasing and "fast forward" merging operations, the master branch incorporated the changes from all branches while maintaining a linear history that is not cluttered with merge commits, making it easier for future developers to maintain the software contained in the repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 100.0%