---
# System prepended metadata

title: Untitled

---

# Tasks
## Task 0. Initialize a Local Repository and Push to GitHub

**Objective:** Learn how to create a file locally, initialize a Git repository, commit your changes, and push the repository to GitHub. this will teach you how to turn a folder from your laptop to a github repository

Skills Practiced:

    Initializing a Git repository
    Basic Git commands (add, commit, push)
    Creating a new repository on GitHub
    Pushing a local repository to GitHub

Task Steps:

### Create a New File Locally:
        On your computer, create a new directory named LocalRepoProject.
        Inside this directory, create a file named hello.txt.
        Open hello.txt in a text editor and add the following content:

     "Hello, Git and GitHub!"

### Initialize a Git Repository:
        Open a terminal or command prompt.
        Navigate to the LocalRepoProject directory.
        Run the following command to initialize a new Git repository:

   `git init`

### Commit Your File to the Repository:
    Add hello.txt to the staging area with the command: `git add hello.txt`

    Commit the file to your repository: `git commit -m "Add hello.txt with greeting"`

### Create a New Repository on GitHub:
        Log in to your GitHub account.
        Click the New button (or navigate to this link) to create a new repository.
        Name your repository LocalRepoProject. Do not initialize the repository with a README, .gitignore, or license.
        Click Create repository.

### Push the Local Repository to GitHub:
    After creating the repository on GitHub, you’ll be shown a URL for the repository. Copy this URL.
    Back in your terminal, link your local repository to GitHub with the command:

     `git remote add origin <REPOSITORY-URL>`
    NOTE: replace <REPOSITORY-URL> with the url you copied

    Push your commits to GitHub: `git push -u origin main`

### Expected Outcome:

You will have a local Git repository with a single file (hello.txt) committed. This repository will be pushed to GitHub, where the file will be visible in your new LocalRepoProject repository.


### Notes:

    This project is designed to introduce the fundamental workflow of using Git locally and pushing changes to a remote repository on GitHub.
    Ensure you replace <REPOSITORY-URL> with the actual URL provided by GitHub when you create your online repository.

### Repo:

    GitHub repository: LocalRepoProject
    File: hello.txt

<hr>

## Task 1. Clone a GitHub Repository and Add New Content


Objective: Familiarize yourself with the process of cloning an existing repository from GitHub, adding new content to it, and pushing the changes back to GitHub.

Skills Practiced:

    Cloning a repository from GitHub
    Editing files and committing changes in a Git-enabled directory
    Pushing updates to a remote repository

## Task Steps:

### Create a New Repository on GitHub:
        Log in to your GitHub account.
        Navigate to the repository creation page (https://github.com/new).
        Name your repository GitHubCloneProject.
        Choose the visibility as public.
        Click Create repository.

### Clone the Repository:
        Once the repository is created, copy the HTTPS link as shown in the above image.
        Open your terminal or command prompt.
        Choose a suitable directory on your local machine where you want to clone the repository.
        Execute the clone command:

     `git clone <REPOSITORY-URL>`

    NOTE: Replace <REPOSITORY-URL> with the URL you copied from GitHub.

### Add New Content:
    Navigate into the cloned repository’s directory:

     `cd GitHubCloneProject`

### Create a new file named greetings.txt.

    Edit greetings.txt in your text editor and add the following content:

     "Hello, this is a message from my cloned repository!"

    Create a new file called README.md and put the text: "This is the description of my repo into it".

### Commit and Push Your Changes:
    Add the new file to the staging area:

        `git add .`

    Commit the new file to your local repository:

         `git commit -m "Add greetings.txt and README.md"`

    Push your changes to the GitHub repository:

         `git push origin main`

### Expected Outcome:

Your GitHub repository GitHubCloneProject will now include a greetings.txt file with the specified content. This demonstrates your ability to clone a repository, make changes locally, and push those changes back to the remote repository.

### Notes:

    This project reinforces the concept of remote repositories and introduces you to managing and updating project content after cloning it from GitHub.
    Remember to replace <REPOSITORY-URL> with your repository’s actual URL provided by GitHub.

### Repo:

    GitHub repository: GitHubCloneProject
    File: greetings.txt, README.md

<hr>

## Task 2. Branching, Making Changes, and Resolving Merge Conflicts


**Objective:** Practice creating branches for feature development, merging branches, and resolving merge conflicts to simulate a common collaborative workflow on Git and GitHub.

### Skills Practiced:

    Branching and navigating between branches
    Making changes in different branches and committing those changes
    Merging branches and resolving conflicts

### Task Steps:

    Initial Setup:
        Use the GitHubCloneProject repository created in the previous task.

### Navigate into the repository’s directory:

     `cd GitHubCloneProject`

### Create a New Branch for a Feature:
    Create and switch to a new branch named feature-greeting:

         `git checkout -b feature-greeting`

    Create a new file named feature.txt and add some content related to a feature, for example:

         "This is a new feature."

    Add and commit the change:

         `git add feature.txt`
         `git commit -m "Add feature description"`

    Modify the README.md file by adding a new line just below the first line (Second line in the file):

     "Modification in feature-greeting branch."

### Commit the change:

     `git add README.md`
     `git commit -m "Modify README in feature-greeting branch"`

Push the new branch to github (hint: Feel free to google it’s part of learning)

### Make Changes in the Main Branch:
    Switch back to the main branch:

         `git checkout main`

    Modify the README.md file by adding a new line just below the first line (Second line in the file):

     "Modification in main branch".

### Commit the change:

         `git add README.md`
         `git commit -m "Modify README in main branch"`

### Merge the Feature Branch and Resolve a Conflict:
    Attempt to merge feature-greeting into main:

         `git merge feature-greeting`

    If a merge conflict occurs, open the conflicting file(s) in a text editor. Manually resolve the conflicts by editing the file to keep or integrate both sets of changes.

    After resolving the conflict, add the file to the staging area and commit the merge:

         `git add .`
         `git commit -m "Resolve merge conflict between main and feature-greeting"`

### Push Changes to GitHub:

    Push the updated main branch, including the merged feature and resolved conflict, to GitHub:

         `git push origin main`

### Expected Outcome:

You will have successfully created a new feature branch, made changes in both the feature-greeting and main branches, and resolved a merge conflict resulting from attempting to merge these branches. Your GitHubCloneProject repository on GitHub will reflect these changes and the merge resolution.

### Notes:

    This project simulates a collaborative scenario where changes made in different branches can lead to conflicts. It tests your ability to manage branches, navigate merge conflicts, and maintain a clean project history.
    Replace <REPOSITORY-URL> with your repository’s actual URL.

### Repo:

    GitHub repository: GitHubCloneProject
    File: feature.txt, README.md

