Objective: By the end of this assignment, you will have installed Git on your Windows 10 computer, created a local repository, made your first "commit," and published your work to your GitHub profile.
Prerequisites:
- A Windows 10 computer
- A GitHub account (Already completed!)
Since you are on Windows, we are going to install Git Bash, which gives you a great terminal environment to type your Git commands.
Step 1: Go to the official Git website: https://git-scm.com/download/win
Step 2: Click on "64-bit Git for Windows Setup" to download the installer.
Step 3: Open the downloaded file and click "Next" through the installation. You can leave all the default settings exactly as they are.
Step 4: Once installed, click on your Windows Start menu, search for "Git Bash", and open it. A black command-line window will appear.
Step 5: Tell Git who you are. Type the following commands into Git Bash, hitting Enter after each one. (Replace the placeholders with your actual name and the email you used for GitHub):
git config --global user.name "Your First and Last Name"
git config --global user.email "your.email@example.com"Now, let's create a folder on your computer and turn it into a Git repository.
Step 1: In Git Bash, navigate to your Desktop by typing:
cd ~/DesktopStep 2: Create a new folder for your project called git-assignment:
mkdir git-assignmentStep 3: Move inside that new folder:
cd git-assignmentStep 4: Initialize Git! This command tells Git to start tracking this folder:
git initYou should see a message saying "Initialized empty Git repository..."
A repository isn't very useful if it's empty. Let's add a file.
Step 1: Create a new file called README.md and put some text inside it. Type this exactly:
echo "# Hello GitHub! This is my first repository." > README.mdStep 2: Check the status of your project. This is the most useful command in Git!
git statusYou will see README.md listed in red, meaning Git sees it but isn't tracking it yet.
Step 3: Tell Git to stage the file (prepare it to be saved):
git add README.mdStep 4: Save the changes permanently by making a "commit". We must always include a message explaining what we did:
git commit -m "Initial commit: Added README file"Now we need a place on the internet to send your local code.
Step 1: Open your web browser, go to GitHub.com, and log in.
Step 2: In the top right corner, click the + icon and select "New repository".
Step 3: Name your repository git-assignment.
Step 4: Leave it as "Public".
Step 5:
GitHub will now show you a page with some code snippets. We are going to connect your local folder to this web folder.
Step 1: Go back to your Git Bash window.
Step 2: Ensure your main branch is named main (the new standard) by typing:
git branch -M mainStep 3: Link your local folder to GitHub. Copy the command GitHub gave you that starts with git remote add origin and paste it into Git Bash. It will look something like this:
git remote add origin https://github.com/YOUR-USERNAME/git-assignment.gitStep 4: Upload ("push") your code to GitHub:
git push -u origin main(Note: Because this is your first time, a small Windows pop-up might appear asking you to sign into GitHub. Click "Sign in with your browser" and authorize it.)
Step 1: Go back to your web browser where your GitHub repository page is open.
Step 2: Refresh the page.
Step 3: You should no longer see the setup instructions. Instead, you will see your README.md file with the text "Hello GitHub! This is my first repository." displayed on the screen.
📝 How to Submit Your Assignment:
Copy the URL of your GitHub repository from your browser's address bar (it will look like https://github.com/YourUsername/git-assignment) and paste it into the assignment submission portal.
- Pasting in Git Bash: You cannot use
Ctrl+Vto paste in Git Bash. Instead, right-click inside the black window and click Paste (or useShift + Insert). - The Git Cycle: Every time you edit your project in the future, you will repeat these three commands to update GitHub:
git add .(adds all new changes)git commit -m "Your message here"(saves the changes locally)git push(uploads the changes to GitHub)