Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 

Repository files navigation

Git Ready

Introduction

This project is designed to introduce you to the world of version control and collaboration using Git. Git is a powerful and widely used tool for tracking changes in your projects, collaborating with others, and ensuring the integrity of your code.

Throughout this project, you will embark on a journey of progressively building your Git skills. Starting from the basics, you'll gradually explore more advanced topics, equipping yourself with the essential knowledge and practices for effective version control and collaboration.

Let's Git ready for it!


Instructions

  1. Work Directory:
    To begin, create a work directory and organize all your tasks within it. Each exercise should be encapsulated in its own file, named after the corresponding task for clarity and ease of reference.

  2. Documentation:
    Accompanying your work, provide documentation or a report detailing the process followed for each exercise. This documentation should include any challenges faced, solutions implemented, and lessons learned. It could be in the form of a README file or a separate document. Make sure to show it to the auditor during evaluation.


⚠️ Evaluation Criteria

  • The completion of tasks will be evaluated based on the commit history reflecting the changes made throughout the exercises and the presence of accompanying documentation detailing the process followed.

Setting Up Git

  1. Install Git on your local machine by following the instructions for your operating system on the official Git website.
  2. Configure Git with your username and email address.

Task 1: Git Commits

  1. Create a hello.sh File:
    Inside a subdirectory named hello, create a file hello.sh with the content:

    echo "Hello, World"
  2. Initialize Git:
    Initialize the git repository in the hello directory.

  3. Modify hello.sh:
    Change the content to:

    #!/bin/bash
    echo "Hello, $1"
  4. Stage & Commit Changes:
    Stage the changed file and commit the changes.

  5. Add Comments:
    Modify the hello.sh file to include comments and stage it.

    #!/bin/bash
    
    # Default is "World"
    name=${1:-"World"}
    echo "Hello, $name"
  6. Make Two Separate Commits:

    • Commit the comment in line 3.
    • Commit changes in lines 4 and 5.

Task 2: History

  1. Show the history of the working directory.
  2. Show one-line history for a condensed view showing only commit hashes and messages.
  3. Customize Log Output:
    • Display the last 2 entries.
    • View the commits made within the last 5 minutes.
  4. Personalized Format:
    Show logs with commit hash, date, message, branch, and author name.

Task 3: Check it Out

  1. Restore First Snapshot:
    Revert the working tree to its initial state and print hello.sh.

  2. Restore Second Snapshot:
    Revert to the second most recent snapshot and print the content of hello.sh.

  3. Return to Latest Version:
    Ensure the working directory reflects the latest version of hello.sh on the main branch.


Task 4: Tag me

  1. Tag the Current Version:
    Tag the current version as v1.

  2. Tag the Previous Version:
    Tag the version before the current one as v1-beta.

  3. Navigate Between Tags:
    Move back and forth between tags v1 and v1-beta.

  4. List Tags:
    Display all tags present in the repository.


Task 5: Changed Your Mind?

  1. Revert Comments:
    Modify hello.sh with unwanted comments and revert the change before staging.

    #!/bin/bash
    # This is a bad comment. We want to revert it.
    name=${1:-"World"}
    echo "Hello, $name"
  2. Staging and Cleaning:
    Introduce unwanted changes, stage them, and clean the staging area to discard.

  3. Commit and Revert:
    Add unwanted changes, commit, and revert them back.

  4. Tag & Remove Commits:
    Tag the latest commit with oops, then remove commits made after v1 so the HEAD points to v1.

  5. Show Deleted Logs:
    Display logs with deleted commits, focusing on oops.

  6. Clean Unreferenced Commits:
    Ensure no logs show unreferenced commits.


Task 6: Author Information

  1. Add Author Comment:
    Add an author comment to hello.sh and commit:

    # Author: Jim Weirich
  2. Forgot Email?:
    Add the author’s email without making a new commit, updating the last one.


Task 7: Move it

  1. Move hello.sh:
    Move hello.sh into the lib/ directory and commit the move.

  2. Create Makefile:
    Create a Makefile with the following content and commit it:

    TARGET="lib/hello.sh"
    
    run:
        bash ${TARGET}

Task 8: Blobs, Trees, and Commits

  1. Explore .git/ Directory:
    Navigate to the .git/ directory and explain the purpose of each subdirectory (e.g., objects/, config, refs, HEAD).

  2. Find Latest Object Hash:
    Use Git commands to print the type and content of the latest object hash in .git/objects/.

  3. Dump Directory Tree:
    Use Git commands to dump the directory tree referenced by the latest commit.


Task 9: Branching

  1. Create a New Branch:
    Create and switch to a local branch named greet.

  2. Create greeter.sh:
    Add the following code to lib/greeter.sh and commit:

    #!/bin/bash
    Greeter() {
        who="$1"
        echo "Hello, $who"
    }
  3. Update hello.sh:
    Modify lib/hello.sh to use greeter.sh, stage, and commit.

  4. Update Makefile:
    Update the Makefile to ensure it runs the updated lib/hello.sh file.

  5. Compare Branches:
    Switch back to main and show the differences between main and greet for Makefile, hello.sh, and greeter.sh.

  6. Commit Tree Diagram:
    Draw a diagram illustrating the commit history and branches.


Task 10: Conflicts, Merging, and Rebasing

  1. Merge main into greet:
    Merge changes from main into greet.

  2. Conflict Resolution:
    Modify hello.sh in main, attempt to merge into greet (causing a conflict), resolve it, and commit.

  3. Rebase greet:
    Rebase greet on top of main.

  4. Merge greet into main:
    Merge changes from greet back into main.


Task 11: Local and Remote Repositories

  1. Clone Repository:
    Clone hello as cloned_hello.

  2. Fetch and Merge Changes:
    Make changes to the original repo, commit, and fetch changes into the cloned repo.

  3. Add Remote & Push Branches:
    Add a remote and push main and greet branches.


Task 12: Bare Repositories

  1. Create Bare Repository:
    Create a bare repository named hello.git.

  2. Add Remote:
    Add the bare repo as a remote to the original repo.

  3. Push Changes:
    Push changes from the original repo to the bare repository.


Submission and Evaluation

Your work must be submitted at the Gitea link provided. The evaluation will be based on the correctness of your Git commands and a clear understanding of Git concepts.


Notions Covered

  • Git Branching
  • Merging and Rebasing
  • Local and Remote Repositories
  • Bare Repositories

Git Gud!

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages