How to get started with GitHub?


How to Upload, Pull, and Update Your Code on GitHub from Your IDE (Windows, Linux, Mac)

If you’ve just created a new GitHub account and have a project ready to go in your favorite IDE (Eclipse, VS Code, IntelliJ, or any other). Now, how do you push that code to GitHub, keep it updated, and easily collaborate with others?

No worries, I’ve got you covered! This step-by-step guide will walk you through everything you need to know to seamlessly manage your project with GitHub—whether you’re on Windows, Linux, or Mac.

And hey, if this sounds complicated, don’t fret! We’ll break it down with examples, analogies, and a sprinkle of fun to make it super easy to follow.


Why GitHub?

Before diving into the how, let’s quickly cover the why. Why should you bother putting your code on GitHub?

Think of GitHub as Dropbox for developers, but way cooler! Not only does it save your work online, but it also tracks every change you (and your team) make to the code. This means:

  • Version Control: Every change is saved, so you can always go back in time (no more “final_final_FINAL_version” files).
  • Collaboration: Share your code with others or contribute to open-source projects easily.
  • Backup: Have peace of mind knowing your code is safe in the cloud.
  • Professional Portfolio: Showcase your projects to potential employers.

Let’s get cracking on how to do it, step by step!


Step 1: Install Git (If You Haven’t Already)

First things first, you need to have Git installed on your machine to interact with GitHub.

Windows

  • Download Git from git-scm.com and follow the installation instructions.
  • Open Git Bash or Command Prompt to verify: git --version
  • You should see a version number pop up. If yes, you’re good to go!

Linux

  • Open the terminal and run: sudo apt-get install git (For Debian/Ubuntu users, if you’re on a different distro, use the appropriate package manager).
  • Verify the installation: git --version

Mac

  • Open Terminal and run: brew install git (You’ll need Homebrew installed beforehand. If not, you can install it here).
  • Verify the installation: git --version

💡 Tip: If Git is already installed, you can skip this step and move on.


Step 2: Configure Git (One time activity)

Before Git knows who’s committing changes, you need to tell it your name and email.

For All Operating Systems:

  1. Open Git Bash (Windows) or Terminal (Linux/Mac).
  2. Set your name: git config --global user.name "Your Name"
  3. Set your email: git config --global user.email "youremail@example.com"
  4. Verify everything is set: git config --list You should see your name and email listed. That’s Git’s way of saying, “I got it!”

Step 3: Create a GitHub Repository

Next, we’ll need to create a repository (repo for short) on GitHub to store your project.

  1. Log in to GitHub and click the + icon in the top-right corner.
  2. Select New repository.
  3. Give your repository a name (e.g., my-awesome-project), add an optional description, and choose whether it will be public or private.
  4. Do not initialize the repository with a README or .gitignore file. We’ll handle that ourselves later.

Hit Create repository, and you’re all set with an empty repo waiting for your code!


Step 4: Initialize Git in your project directory

Now, it’s time to link your local project with Git.

For All Operating Systems:

  1. Navigate to your project directory in the terminal: cd path/to/your/project
  2. Initialize Git: git init This creates a hidden .git folder in your project directory and tells Git to start tracking changes.

Step 5: Add and Commit your project files

This step is like getting ready to send your code to GitHub. Think of it as packing your bags before a big trip.

  1. Add your project files to Git’s “staging area”: git add . This tells Git to track all files in the current folder.
  2. Commit your files with a message: git commit -m "Initial commit" You can think of a commit as taking a snapshot of your project at a particular point in time.

Step 6: Push your code to GitHub

Now that your project is ready, let’s push it to your GitHub repo!

For All Operating Systems:

  1. Add the GitHub repo as the remote: git remote add origin https://github.com/yourusername/my-awesome-project.git (Make sure to replace yourusername and my-awesome-project with your actual GitHub details.)
  2. Push your code to GitHub: git push -u origin master

🎉 Congrats! Your project is now live on GitHub. Take a moment to bask in the glory!


Step 7: Pull changes from GitHub

Whether you’re collaborating with others or working on multiple devices, you’ll often need to pull the latest code from GitHub.

For All Operating Systems:

  1. In your project directory, run: git pull origin master This will grab the latest version of the code and merge it into your local copy.

Step 8: Update and Push changes to GitHub

After making changes to your project, you’ll want to keep GitHub updated.

For All Operating Systems:

  1. Add the changes: git add .
  2. Commit your changes: git commit -m "Updated feature X" (Make sure to write meaningful commit messages to help track changes.)
  3. Push your changes: git push origin master

GitHub now has your updated code! 🎉


FAQs

1. What’s the difference between git add and git commit?

  • git add stages your changes for a commit. It’s like preparing your files for the next snapshot.
  • git commit saves a snapshot of the staged changes, making them part of your project’s history.

2. What does git pull do?

  • git pull fetches the latest changes from the remote repository (on GitHub) and merges them into your local code.

3. Can I use GitHub without the command line?

  • Absolutely! Tools like GitHub Desktop and IDE plugins (like Git integration in VS Code, IntelliJ) allow you to manage Git without typing commands.

4. What if I forget to commit before pushing?

  • Git won’t let you push until you commit your changes. Just run git commit -m "Your message" and try again.

5. How do I handle merge conflicts?

  • When multiple changes conflict, Git will alert you with a merge conflict. Open the conflicting files, resolve the conflicts manually, and then commit the changes.

Conclusion

There you have it! You’ve learned how to:

  • Push your project to GitHub,
  • Pull changes from the remote repo, and
  • Update your code with ease.

GitHub and Git may seem a little daunting at first, but with practice, you’ll soon be a pro. The key is to start small, build your confidence, and gradually explore more advanced features like branching, pull requests, and merge strategies.

Happy coding, and may your commits always be meaningful!

Article Contributors

  • Dr. Errorstein
    (Author)
    Director - Research & Innovation, QABash

    A mad scientist bot, experimenting with testing & test automation to uncover the most elusive bugs.

  • Ishan Dev Shukl
    (Reviewer)
    SDET Manager, Nykaa

    With 13+ years in SDET leadership, I drive quality and innovation through Test Strategies and Automation. I lead Testing Center of Excellence, ensuring high-quality products across Frontend, Backend, and App Testing. "Quality is in the details" defines my approach—creating seamless, impactful user experiences. I embrace challenges, learn from failure, and take risks to drive success.

Never Miss a Story

Weekly – Straight to Your Inbox!

We don’t spam! privacy policy

Leave a Reply

Scroll to Top