0% found this document useful (0 votes)
14 views

Lab 3

Ntg

Uploaded by

Denny Shorts
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Lab 3

Ntg

Uploaded by

Denny Shorts
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Lab 3: Creating and Using a Git Repository for Software Engineering

Objective:

To learn how to create a Git repository, make commits, and push changes to GitHub.

Prerequisites:

 Git installed on your machine


 GitHub account
 Visual Studio Code (VS Code) installed

Git is a distributed version control system. It’s a system that records changes of our files over
time.

--distributed-even-if-your-workflow-isnt

Lab Steps:

Step 1: Set Up Git and GitHub

1. Install Git:
o Download and install Git from Git's official website.
2. Set Up Git Configuration: Open a terminal and configure your Git username and
email:

git config --global user.name "Your Name"


git config --global user.email "[email protected]"

3. Create a GitHub Account: If you don't have a GitHub account, create one at
GitHub's website.

Step 2: Create a New Repository on GitHub

1. Log In to GitHub: Go to GitHub and log in.


2. Create a New Repository:
o Click on the "+" icon at the top right and select "New repository".
o Fill in the repository name (e.g., my-first-repo).
o Optionally, add a description.
o Choose "Public" or "Private" as per your preference.
o Initialize the repository with a README.md (optional but recommended).
o Click on "Create repository".

Step 3: Clone the Repository Locally

1. Get the Repository URL: On your repository page on GitHub, click the green
"Code" button and copy the URL.
2. Clone the Repository: Open a terminal and run:

git clone https://github.com/yourusername/my-first-repo.git


Replace https://github.com/yourusername/my-first-repo.git with your repository URL.

Step 4: Make Changes and Commit

1. Open the Project in VS Code:

cd my-first-repo
code .
2. Create a New File: In VS Code, create a new file called hello.txt and add some text
to it.
3. Check Git Status:
git status
4. Add Changes to Staging Area:
git add hello.txt
5. Commit Changes:
git commit -m "Add hello.txt with initial content"

Step 5: Push Changes to GitHub

1. Push to GitHub:

git push origin main


Replace main with your branch name if it's different.

Step 6: View Changes on GitHub

1. Go to Your Repository: Open your repository on GitHub in a web browser.


2. Verify the Changes: Ensure that the hello.txt file is present with the content you
added.

Step 7: Additional Practice

1. Create Another File: Create another file called goodbye.txt and add some content.
2. Repeat the Process:
o Add the file to the staging area.
o Commit the changes.
o Push the changes to GitHub.

Check out:

 Branching and Merging: Explore creating branches using git branch and git
checkout -b branch_name, and learn to merge using git merge.
 Pull Requests: Learn how to create pull requests on GitHub for collaborative work.
 GitHub Pages: If you're interested in hosting a static site, explore GitHub Pages.

Additional Resources:

 Pro Git Book


 GitHub Learning Lab

You might also like