DEV Community

Cover image for 🚀 Creating Your First GitHub Repository and Committing Your First File 📝
Evan Charalampidis
Evan Charalampidis

Posted on

🚀 Creating Your First GitHub Repository and Committing Your First File 📝

Welcome back! In our previous article, we introduced you to Git and GitHub. Now, it's time to dive deeper and learn how to create a GitHub repository and make your first commit. Let's get started!

Step 1: Create a GitHub Repository 🗂️

1.1 Sign In to GitHub 🔑
First, sign in to your GitHub account. If you don't have an account yet, you can sign up at github.com.

Once logged in, click the + icon in the top-right corner and select New repository. Fill in the repository details:

  1. Repository name: Give your repository a unique name.
  2. Description: Optionally, add a short description of your project.
  3. Public or Private: Choose the visibility of your repository.
  4. Initialize this repository with a README: Check this box to add a README file.
  5. Click Create repository.

🎉 Congratulations! You have created your first GitHub repository.

Step 2: Clone the Repository to Your Local Machine 💻

To start working on your project locally, you need to clone the repository.

  • On your repository page, click the green Code button.
  • Copy the repository URL (either HTTPS or SSH).
  • Open your terminal and run the following command:
git clone https://github.com/your-username/your-repository.git
Enter fullscreen mode Exit fullscreen mode

Replace your-username and your-repository with your GitHub username and repository name, respectively.

Step 3: Navigate to Your Repository 📂

Change your directory to the newly cloned repository:

cd your-repository
Enter fullscreen mode Exit fullscreen mode

Step 4: Create Your First File 📄

Now, let's create a new file and add some content to it.

  • Create a new file named hello_world.txt:
echo "Hello, World!" > hello_world.txt
Enter fullscreen mode Exit fullscreen mode
  • Verify that the file has been created:
ls
Enter fullscreen mode Exit fullscreen mode

You should see hello_world.txt in the list of files.

Step 5: Commit Your First File ✅

5.1 Add the File to the Staging Area 📤

Before committing, you need to add the file to the staging area:

git add hello_world.txt
Enter fullscreen mode Exit fullscreen mode

5.2 Commit the File 📝

Now, commit the file with a descriptive message:

git commit -m "Add hello_world.txt with a greeting message"
Enter fullscreen mode Exit fullscreen mode

5.3 Push the Changes to GitHub 🌐

Finally, push the changes to your GitHub repository:

git push origin main
Enter fullscreen mode Exit fullscreen mode

Conclusion 🎯

You've successfully created a GitHub repository, cloned it to your local machine, created a file, and committed it to the repository. Great job!

In the next article, we'll explore branching in Git and how to work with multiple collaborators. Stay tuned!

Feel free to leave comments or ask questions below.

Happy coding! 👩‍💻👨‍💻
Follow me on GitHub for more updates and check out my other articles on Dev.to.

Github: @imevanc
Twitter: @imevancc

Top comments (0)