Exercises Directory

EXERCISE: under-control

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download under-control command.

Scenario:

Your task:

When you download a Git-Mastery exercise, the output will tell you which directory you need to cd into, for you to start the exercise:

Put the folder under-control/control-me under Git's control (i.e., initialise a repository in the control-me folder).


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/under-control folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/under-control folder and run the gitmastery progress reset command.


EXERCISE: undo-init

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download undo-init command.

Scenario:

You initialised a git repository in the my-notes folder by mistake.

Your task:

Undo the repo initialisation, without deleting any of the original files that were in that folder.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/undo-init folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/undo-init folder and run the gitmastery progress reset command.


EXERCISE: stage-fright

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download stage-fright command.

Scenario:

Your task:

The attendance repo has three unstaged files. Stage them.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/stage-fright folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/stage-fright folder and run the gitmastery progress reset command.


EXERCISE: staging-intervention

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download staging-intervention command.

Scenario:

Your task:

In the repo intervention given, unstage the following files: adam.txt, josh.txt, mary.txt. Keep other files staged.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/staging-intervention folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/staging-intervention folder and run the gitmastery progress reset command.


EXERCISE: grocery-shopping

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download grocery-shopping command.

Scenario:

Your task:

In the shopping-list repo given, there is a shopping-list.txt.

  1. Edit it (using any text editor) to remove at least one item from the shopping list and add at least one new item to the shopping list.
  2. Stage the change and commit it.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/grocery-shopping folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/grocery-shopping folder and run the gitmastery progress reset command.


EXERCISE: log-and-order

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download log-and-order command.

Scenario:

You are given a repo crime-spree (apparently, containing details of some crimes).

Your task:

  1. Open the log-and-order/answers.txt file to find the questions you need to answer.
  2. Examine the list of commits in the crime-spree repo to find the answers.
  3. Enter your answers in the answers.txt file.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/log-and-order folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/log-and-order folder and run the gitmastery progress reset command.


EXERCISE: remote-control

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download remote-control command.

Scenario:

Your task:

  1. As per the usual practice, cd into the remote-control folder.
  2. Run gitmastery verify command.
  3. Take note of the repo name provided by Git-Mastery app (in its response).
  4. Create a new public GitHub repository using the repo name given.
  5. Provide the URL of that remote (without the .git at the end) when prompted
    e.g., https://github.com/johndoe/gitmastery-johndoe-remote-control

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/remote-control folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/remote-control folder and run the gitmastery progress reset command.


To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download link-me command.

Scenario:

Your task:

In the link-this repo provided, add the git-mastery/link-me repository as a remote named upstream.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/link-me folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/link-me folder and run the gitmastery progress reset command.


EXERCISE: push-over

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download push-over command.

Scenario:

Your task:

Create a new commit on the main branch of the local repo in push-this folder, and push the updated main branch to the remote.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/push-over folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/push-over folder and run the gitmastery progress reset command.


EXERCISE: ignoring-somethings

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download ignoring-somethings command.

Scenario:

Your task:

1. Update the .gitignore file (inside the files/ folder) to reflect the following requirements:

  • Git should ignore every file in the many/ folder except the file many/file22.txt.
  • why_am_i_hidden.txt should not be ignored by Git.
  • ignore_me.txt should be ignored by Git.
  • Git should ignore any runaway.txt file in this/ and any of its current and future subfolders (hint: use a pattern).

2. Commit the updated .gitignore file.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/ignoring-somethings folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/ignoring-somethings folder and run the gitmastery progress reset command.


EXERCISE: fork-repo

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download fork-repo command.

Scenario:

Your task:

Fork the repo https://github.com/git-mastery/gm-shapes to your GitHub account, while retaining the original repo name gm-shapes.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/fork-repo folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/fork-repo folder and run the gitmastery progress reset command.


EXERCISE: clone-repo

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download clone-repo command.

Scenario:

Your task:

  1. Fork the repo https://github.com/git-mastery/gm-shapes to your GitHub account, if you haven't done so already. Retain the original repo name gm-shapes.
  2. Clone the fork to your computer, placing it in the folder clone-repo/shapes (note how the target folder is shapes, not gm-shapes).
    If you did this step correctly, you should now have local repo shapes.
  3. Set up a remote named upstream in that shapes repo, to point to the upstream repo git-mastery/gm-shapes.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/clone-repo folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/clone-repo folder and run the gitmastery progress reset command.


EXERCISE: fetch-and-pull

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download fetch-and-pull command.

Scenario:

Your task:

You have been given a clone of the git-mastery/gm-shapes repo.

  1. Another developer Alice has created a remote copy of this repo at https://github.com/git-mastery/gm-shapes-alice which seems to have an additional commit in the main branch.
    • Add that repo as a remote named alice-upstream.
    • Bring over Alice's additional commit to your repo.
  2. Alice's friend Bob has copied Alice's repo to https://github.com/git-mastery/gm-shapes-bob, and added one more commit.
    • Add that repo as another remote named bob-upstream.
    • Download the metadata about this new commit (i.e., fetch, not pull or merge) to your repo.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/fetch-and-pull folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/fetch-and-pull folder and run the gitmastery progress reset command.


EXERCISE: view-commits

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download view-commits command.

Scenario:

The duty-roster repo contains five files, each one containing names of people assigned to a duty roster for a specific day of the week. For example, Monday.txt contains names of people assigned to duties on Mondays. These files are updated monthly, to record any changes to duty assignments.

Your task:

Answer the questions in the answers.txt, by examining the relevant commits in the duty-roster repo.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/view-commits folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/view-commits folder and run the gitmastery progress reset command.


EXERCISE: tags-add

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download tags-add command.

Scenario:

The duty-roster repo contains text files that track which people are assigned for duties on which days of the week.

Your task:

  1. Add a lightweight tag first-pilot to the first commit of the repo.
  2. Add the annotated tag v1.0 to the commit that updates March duty roster. The tag should have the message first full duty roster.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/tags-add folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/tags-add folder and run the gitmastery progress reset command.


EXERCISE: tags-update

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download tags-update command.

Scenario:

The duty-roster repo contains text files that track which people are assigned for duties on which days of the week. Some of the tags added earlier have been found to be incorrect.

Your task:

  1. To make tag names consistent, change first-update tag to january-update.
  2. Theapril-update tag is currently pointing to the commit that updates the duty roster for May. Move it to the correct commit.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/tags-update folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/tags-update folder and run the gitmastery progress reset command.


EXERCISE: tags-push

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download tags-push command.

Scenario:

The duty-roster repo contains text files that track which people are assigned for duties on which days of the week. This repo is backed up in a remote named production. Apparently, tags in the local repo are not in sync with the tags in your remote.

Your task:

Rectify the out-of-sync tags as follows:

  1. Push both tags in the local repo to the remote.
  2. If any tags are present in the remote production but not in the local repo (i.e., likely result of you previously deleting them in the local repo but forgetting to delete them in the remote repo), delete them in the remote.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/tags-push folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/tags-push folder and run the gitmastery progress reset command.


EXERCISE: sensors-diff

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download sensors-diff command.

Scenario:

A system is using Git to record data received daily from four sensors, each monitoring one of directions east, west, north, south. Each sensor provides 20 integer values, which are stored in a csv file (e.g., values from the sensor monitoring the east direction are recorded as east.csv). Data for each day is recorded as one commit.

Your task:

Examine the revision history to answer the following questions.

Q: Which are the new values in staged files?

Q: Which are the new values in modified but unstaged files?

Q: Which files have changed from Jan 09th to Jan 15th?

Q: Which new values are new in north.csv on Jan 10th, compared to Jan 01st?


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/sensors-diff folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/sensors-diff folder and run the gitmastery progress reset command.


EXERCISE: sensors-checkout

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download sensors-checkout command.

Scenario:

Same as the scenario in exercise sensors-diff. Repeated below for ease of reference:

A system is using Git to record data received daily from four sensors, each monitoring one of directions east, west, north, south. Each sensor provides 20 integer values, which are stored in a csv file (e.g., values from the sensor monitoring the east direction are recorded as east.csv). Data for each day is recorded as one commit.

Your task:

Traverse the revision history to answer the following questions.

Q1: What's sum of values in south.csv on Jan 11th?

You can use the bash command awk '{s+=$1} END {print s}' south.csv to find the sum of values in south.csv (and so on). Alternatively, you can open the csv file in a spreadsheet program and use a feature of that program to find the sum.

Q2: What's sum of values in west.csv on Jan 09th?

Q3: What's sum of values in north.csv on Jan 05th?


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/sensors-checkout folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/sensors-checkout folder and run the gitmastery progress reset command.


EXERCISE: sensors-reset

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download sensors-reset command.

Scenario:

The background is same as the scenario in exercise sensors-diff, repeated below for ease of reference:

A system is using Git to record data received daily from four sensors, each monitoring one of directions east, west, north, south. Each sensor provides 20 integer values, which are stored in a csv file (e.g., values from the sensor monitoring the east direction are recorded as east.csv). Data for each day is recorded as one commit.

Now, you have found that the last few commits have some problems, might need some manual fixes.

Your task:

In preparation for the manual fixes to problematic commits, do the following steps.

  1. Discard the last two commits entirely. They are totally incorrect.
  2. Discard the next commit (i.e., data for Jan 13) but keep the changes in the working directory. They need some major changes, which you'll do later.
  3. Discard the next commit (i.e., data for Jan 12) but keep the changes staged. You will do some minor changes to them and commit them again soon.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/sensors-reset folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/sensors-reset folder and run the gitmastery progress reset command.


EXERCISE: sensors-revert

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download sensors-revert command.

Scenario:

The background is same as the scenario in exercise sensors-diff, repeated below for ease of reference:

A system is using Git to record data received daily from four sensors, each monitoring one of directions east, west, north, south. Each sensor provides 20 integer values, which are stored in a csv file (e.g., values from the sensor monitoring the east direction are recorded as east.csv). Data for each day is recorded as one commit.

Now, you have found that the last few commits have some problems. You wish to reverse those commits, without changing any of the current commits so that problematic commits are preserved in history for future reference.

Your task:

Use Git's revert feature to reverse the problematic commits, as follows:

  1. Revert the commit containing data for Jan 14th. Keep the default commit message.
  2. Do the same for Jan 13th.

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/sensors-revert folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/sensors-revert folder and run the gitmastery progress reset command.


EXERCISE: side-track

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download side-track command.

Scenario:

Your task:

While you are working on a small Python project in the branch-me repo, you discovered two bugs. You wish to fix them in a separate branch named bug-fix, as two separate commits.

The steps to follow are given below:

This repo uses main (not master) as the default branch.

  1. Create a branch named bug-fix.
    Switch to that branch.
  2. Update the greet.py file so that the greet function uses the name variable in the output, as follows:
    -    print("Hi Alice")
    +    print(f"Hi {name}")
    
    Commit the changes.
  3. Update the calculator.py file such that the add function returns the sum of two numbers, as follows:
     def add(a, b):
    -    return a - b
    +    return a + b
    
    Commit the changes.
  4. Switch back to the main branch.

The final result should be something like this:

gitGraph BT:
    %%{init: { 'theme': 'default', 'gitGraph': {'mainBranchName': 'main'}} }%%
    commit id: "[HEAD → main] ..."
    branch bug-fix
    commit id: "Fix greet.py"
    commit id: "[feature] Fix calculator.py"
    checkout main

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/side-track folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/side-track folder and run the gitmastery progress reset command.


EXERCISE: branch-previous

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-previous command.

Scenario:

You are writing the outline for a story, in story.txt. You have written the first few steps of the storyline.

Curren revision graph:

gitGraph BT:
  commit id: "Describe night"
  commit id: "Describe location"
  commit id: "Mention noise"

You are not very happy with the way the story is progressing, and wish to explore a few alternative storylines starting from a previous step.

Your task:

  1. Start a new branch named visitor-line, starting from the second commit (i.e., commit Describe location).
  2. Add the line I heard someone knocking at the door. to the story.txt.
  3. Commit the change. You may use any suitable commit message.
  4. Start a new branch named sleep-line, starting from the same starting point as before.
  5. Add the line I fell asleep on the couch. to the story.txt.
  6. Commit the change. You may use any suitable commit message.

Expected revision graph:

gitGraph BT:
  commit id: "Describe night"
  commit id: "Describe location"
  branch visitor-line
  checkout main
  branch sleep-line
  checkout main
  commit id: "Mention noise"
  checkout visitor-line
  commit id: "Mention knocking"
  checkout sleep-line
  commit id: "Mention sleeping"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-previous folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-previous folder and run the gitmastery progress reset command.


EXERCISE: branch-compare

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-compare command.

Scenario:

You are recording a numerical data stream from two sources. The data are stored in data.txt, using a different branch for each stream. The two data streams are supposed to be identical but can vary on rare occasions.

Your task:

Compare the two branches to determine the answers to the following questions:

Q: Which numbers are present in stream-1 but not in stream-2?

Q: Which numbers are present in stream-2 but not in stream-1?


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-compare folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-compare folder and run the gitmastery progress reset command.


EXERCISE: branch-bender

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-bender command.

Scenario:

Your task:

Do the following operations in the given webapp repo, in the given order:

  1. Merge feature/login onto the main branch, while ensuring a merge commit is created (i.e., no fast-forwarding).
  2. Merge feature/dashboard onto the main branch.
  3. Merge feature/payments onto the main branch.

The final result should look like this:

gitGraph
commit
branch feature/login
checkout main
branch feature/dashboard
checkout main
branch feature/payments
checkout feature/login
commit
commit
checkout main
merge feature/login
checkout feature/dashboard
commit
commit
commit
checkout main
merge feature/dashboard
checkout feature/payments
commit
commit
checkout main
merge feature/payments

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-bender folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-bender folder and run the gitmastery progress reset command.


EXERCISE: branch-forward

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-forward command.

Scenario:

You are writing the outline for a story. You now have two parallel storylines in two branches.

Your task:

Merge only the branch(es) that can be fast-forwarded. Use fast-forward merging.

Tip: Ensure you have switched to the destination branch before initiating the merge.


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-forward folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-forward folder and run the gitmastery progress reset command.


EXERCISE: merge-undo

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download merge-undo command.

Scenario:

You are keeping notes on the characters of a play that you are writing. In the main story line (which is in the main branch), you introduced two characters, Rick and Morty. You had two other characters in two separate branches daughter and son-in-law. Just now, you introduced these two characters to the main story line by merging the two branches to the main branch.

gitGraph BT:
    commit id: "Add Rick"
    branch daughter
    branch son-in-law
    checkout daughter
    commit id: "[daughter] Add Beth"
    checkout son-in-law
    commit id: "[son-in-law] Add Jerry"
    checkout main
    commit id: "Add Morty"
    merge daughter id: "Merge daughter"
    merge son-in-law id: "[HEAD → main] Merge son-in-law"

However, now you realise this is premature, and wish to undo that change.

Your task:

Undo the merging of branches son-in-law and daughter. The result should be as follows:

gitGraph BT:
    commit id: "Add Rick"
    branch daughter
    branch son-in-law
    checkout daughter
    commit id: "[daughter] Add Beth"
    checkout son-in-law
    commit id: "[son-in-law] Add Jerry"
    checkout main
    commit id: "[HEAD → main] Add Morty"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/merge-undo folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/merge-undo folder and run the gitmastery progress reset command.


EXERCISE: ff-undo

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download ff-undo command.

Scenario:

You are keeping notes on the characters of a play that you are writing. In the main story line (which is in the main branch), you introduced two characters, Rick and Morty. You added a few other characters in a separate branch others.

gitGraph BT:
    commit id: "Add Rick"
    commit id: "[main] Add Morty"
    branch others
    commit id: "Add Birdperson"
    commit id: "Add Cyborg to birdperson.txt"
    commit id: "[HEAD → other] Add Tammy"

Just now, you did a fast-forward merge of the others branch to the main branch.

gitGraph BT:
    commit id: "Add Rick"
    commit id: "Add Morty"
    commit id: "Add Birdperson"
    commit id: "Add Cyborg to birdperson.txt"
    commit id: "[HEAD → main][others] Add Tammy"

However, now you realise this is premature, and wish to undo that change.

Your task:

Undo the merging of branch others.

The result should be as follows:

gitGraph BT:
    commit id: "Add Rick"
    commit id: "[HEAD → main] Add Morty"
    branch others
    commit id: "Add Birdperson"
    commit id: "Add Cyborg to birdperson.txt"
    commit id: "[other] Add Tammy"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/ff-undo folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/ff-undo folder and run the gitmastery progress reset command.


EXERCISE: merge-squash

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download merge-squash command.

Scenario:

You are keeping notes on the cast of a sitcom you've started watching. Initially, you kept main cast and supporting cast on two separate branches.

gitGraph BT:
  commit id: "Add Joey"
  commit id: "Add Phoebe"
  branch supporting
  checkout supporting
  commit id: "Add Mike"
  commit id: "Add Janice"
  checkout main
  commit id: "Add Ross"

Now you wish to keep everything in the main branch.

Your task:

Squash-merge the supporting-cast branch onto the main branch. You may use any suitable commit message. The result should be as follows:

gitGraph BT:
  commit id: "Add Joey"
  commit id: "Add Phoebe"
  commit id: "Add Ross"
  commit id: "Add Mike and Janice"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/merge-squash folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/merge-squash folder and run the gitmastery progress reset command.


EXERCISE: conflict-mediator

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download conflict-mediator command.

Scenario:

Your task:

The given repo conflict has an unmerged branch josh and a merged branch john.
Merge branch josh onto main. This will result in a merge conflict in the script.py file.
Resolve the merge conflict and complete the merge.
The intended outcome is print('Hello Everyone and World!').


To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/conflict-mediator folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/conflict-mediator folder and run the gitmastery progress reset command.


EXERCISE: branch-rename

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-rename command.

Scenario:

In the rename-this repo, you have been working on the login feature for your application on the branch login. On second thoughts, you now wish you had named it feature/login, to indicate the category of work done in the branch.

gitGraph BT:
    commit id: "m1"
    commit id: "m2"
    branch login
    commit id: "b1"
    checkout main
    commit id: "[HEAD → main] m3"
    checkout login
    commit id: "[login] b2"

Your task:

In the rename-this repo, rename the login branch to feature/login.

Expected result:

gitGraph BT:
    commit id: "m1"
    commit id: "m2"
    branch feature/login
    commit id: "b1"
    checkout main
    commit id: "[HEAD → main] m3"
    checkout feature/login
    commit id: "[feature/login] b2"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-rename folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-rename folder and run the gitmastery progress reset command.


EXERCISE: branch-delete

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download branch-delete command.

Scenario:

In the delete-my-branches repo, you were trying out two alternative optimisation approaches in two parallel branches optimization-approach-1 and optimization-approach-2, to decide which one is better.

You decided that the approach in the branch optimization-approach-1 is better and merged it. As the work has already been merged, you can now delete that branch to reduce clutter.

gitGraph BT:
    commit id: "Implement loading"
    commit id: "Fix loading bug"
    branch opt...approach-1
    commit id: "Apply bubble sort"
    commit id: "[opti...-1] Fix sorting bug"
    checkout main
    branch opt...approach-2
    commit id: "[opti...-2] Apply merge sort"
    checkout main
    merge opt...approach-1 id: "[HEAD → main] Merge ...'...approach-1"

Since you no longer need the work done in the branch optimization-approach-2, you can discard it by deleting the branch.

Your task:

  1. Delete the optimization-approach-1 branch.
  2. Delete the optimization-approach-2 branch as well.

Expected outcome:

gitGraph BT:
    commit id: "Implement loading"
    commit id: "Fix loading bug"
    branch _
    commit id: "Apply bubble sort"
    commit id: "Fix sorting bug"
    checkout main
    merge _ id: "[HEAD → main] Merge ...'...approach-1"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/branch-delete folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/branch-delete folder and run the gitmastery progress reset command.


EXERCISE: mix-messy-docs

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download mix-messy-docs command.

Scenario:

You are writing user documentation for a product. You have already written documentation for a few new features, each in a separate branch. You wish to accumulate this work in a separate branch called development until the next product release.

gitGraph BT:
  commit id: "Add features.md"
  commit id: "Mention feature for creating books" tag: "v10"
  branch feature-search
  branch feature-delete
  branch list
  checkout feature-delete
  commit id: "Mention feature for deleting books"
  checkout feature-search
  commit id: "Mention feature for searching books"
  checkout feature-delete
  commit id: "Add missing period"
  checkout main
  commit id: "Fix phrasing of heading"
  checkout feature-search
  commit id: "Add more details on the search feature"
  checkout list
  commit id: "Add partial docs for listing books"

Your task:

  1. Create a new branch development, starting from the commit tagged v1.0
  2. Merge the feature-search branch onto the development branch, without using fast-forwarding (i.e., create a merge commit). Delete the feature-search branch.
  3. Similarly, merge the feature-delete branch onto the development branch. Resolve any merge conflicts -- in the features.md, the delete feature should appear after the search feature (see below). Delete the feature-delete branch.
    features.md
    # Features
    
    ## Create Book
    
    Allows creating one book at a time.
    
    ## Searching for Books
    
    Allows searching for books by keywords.
    Works only for book titles.
    
    ## Deleting Books
    
    Allows deleting books.
    
  4. The list branch is not yet ready to be merged but rename it as feature-list, to be consistent with the naming convention you have been following in this repo.

Expected final result:

gitGraph BT:
  commit id: "Add features.md"
  commit id: "Mention feature for creating books" tag: "v10"
  branch DELETED_feature-search
  branch DELETED_feature-delete
  branch feature-list
  branch development
  checkout DELETED_feature-delete
  commit id: "Mention feature for deleting books"
  checkout DELETED_feature-search
  commit id: "Mention feature for searching books"
  checkout DELETED_feature-delete
  commit id: "Add missing period"
  checkout main
  commit id: "Fix phrasing of heading"
  checkout DELETED_feature-search
  commit id: "Add more details on the search feature"
  checkout feature-list
  commit id: "Add partial docs for listing books"
  checkout development
  merge DELETED_feature-search
  merge DELETED_feature-delete

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/mix-messy-docs folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/mix-messy-docs folder and run the gitmastery progress reset command.


EXERCISE: mix-messy-graph

To download the exercise:

  • Navigate inside the gitmastery-exercises folder.
  • Run gitmastery download mix-messy-graph command.

Scenario:

You are writing user documentation for a product. You have already written documentation for a few new features, each in a separate branch. You have merged the feature-search branch.

gitGraph BT:
  commit id: "Add features.md"
  commit id: "Mention feature for creating books" tag: "v10"
  branch feature-search
  branch feature-delete
  branch list
  checkout feature-delete
  commit id: "Mention feature for deleting books"
  checkout feature-search
  commit id: "Mention feature for searching books"
  checkout feature-delete
  commit id: "Add missing period"
  checkout main
  commit id: "Fix phrasing of heading"
  checkout feature-search
  commit id: "Add more details on the search feature"
  checkout list
  commit id: "Add partial docs for listing books"
  checkout main
  merge feature-search id: "Merge search feature"

At this point, you realise this way of merging can result in a complicated revision graph. Instead, you wish to merge these changes in a way that results in a simple linear revision graph.

Your task:

  1. Undo the merging of feature-search.

  2. Squash-merge the feature-search branch onto the main branch with the commit message Add the search feature. Delete the feature-search branch.

  3. Similarly, squash-merge and delete the feature-delete branch with the commit message Add the delete feature, while resolving any merge conflicts -- in the features.md, the delete feature should appear after the search feature (expected content given below):

    features.md
    # Features
    
    ## Creating Books
    
    Allows creating one book at a time.
    
    ## Searching for Books
    
    Allows searching for books by keywords.
    Works only for book titles.
    
    ## Deleting Books
    
    Allows deleting books.
    
  4. The list branch is not needed, as you have decided not to have that feature. Delete that branch. The resulting revision graph should be as follows:

gitGraph BT:
  commit id: "Add features.md"
  commit id: "Mention feature for creating books" tag: "v10"
  commit id: "Fix phrasing of heading"
  commit id: "Add the search feature"
  commit id: "Add the delete feature"

To verify your work:

  • Navigate to anywhere inside the gitmastery-exercises/mix-messy-graph folder (or any sub-folder of it).
  • Run the gitmastery verify command.

To reset the exercise and start over, navigate to the gitmastery-exercises/mix-messy-graph folder and run the gitmastery progress reset command.


Total exercises: 34