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!
-
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. -
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.
- 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.
- Install Git on your local machine by following the instructions for your operating system on the official Git website.
- Configure Git with your username and email address.
-
Create a
hello.shFile:
Inside a subdirectory namedhello, create a filehello.shwith the content:echo "Hello, World"
-
Initialize Git:
Initialize the git repository in thehellodirectory. -
Modify
hello.sh:
Change the content to:#!/bin/bash echo "Hello, $1"
-
Stage & Commit Changes:
Stage the changed file and commit the changes. -
Add Comments:
Modify thehello.shfile to include comments and stage it.#!/bin/bash # Default is "World" name=${1:-"World"} echo "Hello, $name"
-
Make Two Separate Commits:
- Commit the comment in line 3.
- Commit changes in lines 4 and 5.
- Show the history of the working directory.
- Show one-line history for a condensed view showing only commit hashes and messages.
- Customize Log Output:
- Display the last 2 entries.
- View the commits made within the last 5 minutes.
- Personalized Format:
Show logs with commit hash, date, message, branch, and author name.
-
Restore First Snapshot:
Revert the working tree to its initial state and printhello.sh. -
Restore Second Snapshot:
Revert to the second most recent snapshot and print the content ofhello.sh. -
Return to Latest Version:
Ensure the working directory reflects the latest version ofhello.shon themainbranch.
-
Tag the Current Version:
Tag the current version asv1. -
Tag the Previous Version:
Tag the version before the current one asv1-beta. -
Navigate Between Tags:
Move back and forth between tagsv1andv1-beta. -
List Tags:
Display all tags present in the repository.
-
Revert Comments:
Modifyhello.shwith 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"
-
Staging and Cleaning:
Introduce unwanted changes, stage them, and clean the staging area to discard. -
Commit and Revert:
Add unwanted changes, commit, and revert them back. -
Tag & Remove Commits:
Tag the latest commit withoops, then remove commits made afterv1so theHEADpoints tov1. -
Show Deleted Logs:
Display logs with deleted commits, focusing onoops. -
Clean Unreferenced Commits:
Ensure no logs show unreferenced commits.
-
Add Author Comment:
Add an author comment tohello.shand commit:# Author: Jim Weirich -
Forgot Email?:
Add the author’s email without making a new commit, updating the last one.
-
Move
hello.sh:
Movehello.shinto thelib/directory and commit the move. -
Create
Makefile:
Create aMakefilewith the following content and commit it:TARGET="lib/hello.sh" run: bash ${TARGET}
-
Explore
.git/Directory:
Navigate to the.git/directory and explain the purpose of each subdirectory (e.g.,objects/,config,refs,HEAD). -
Find Latest Object Hash:
Use Git commands to print the type and content of the latest object hash in.git/objects/. -
Dump Directory Tree:
Use Git commands to dump the directory tree referenced by the latest commit.
-
Create a New Branch:
Create and switch to a local branch namedgreet. -
Create
greeter.sh:
Add the following code tolib/greeter.shand commit:#!/bin/bash Greeter() { who="$1" echo "Hello, $who" }
-
Update
hello.sh:
Modifylib/hello.shto usegreeter.sh, stage, and commit. -
Update
Makefile:
Update theMakefileto ensure it runs the updatedlib/hello.shfile. -
Compare Branches:
Switch back tomainand show the differences betweenmainandgreetforMakefile,hello.sh, andgreeter.sh. -
Commit Tree Diagram:
Draw a diagram illustrating the commit history and branches.
-
Merge
mainintogreet:
Merge changes frommainintogreet. -
Conflict Resolution:
Modifyhello.shinmain, attempt to merge intogreet(causing a conflict), resolve it, and commit. -
Rebase
greet:
Rebasegreeton top ofmain. -
Merge
greetintomain:
Merge changes fromgreetback intomain.
-
Clone Repository:
Clonehelloascloned_hello. -
Fetch and Merge Changes:
Make changes to the original repo, commit, and fetch changes into the cloned repo. -
Add Remote & Push Branches:
Add a remote and pushmainandgreetbranches.
-
Create Bare Repository:
Create a bare repository namedhello.git. -
Add Remote:
Add the bare repo as a remote to the original repo. -
Push Changes:
Push changes from the original repo to the bare repository.
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.
- Git Branching
- Merging and Rebasing
- Local and Remote Repositories
- Bare Repositories
Git Gud!