Globe Icon

Based in Lagos, Nigeria

6.52° N, 3.38° E

Globe Icon

Based in Lagos, Nigeria

6.52° N, 3.38° E

Git and Github for beginners

Git & Github

Feb 17, 2025

Introduction

Git and GitHub are essential tools in modern software development. They allow developers to manage different versions of their code, collaborate effectively, and maintain a streamlined workflow.

What is Git?

Git is a distributed version control system (VCS) that helps developers track changes in their codebase, collaborate efficiently, and manage project versions. The term "distributed" means that each developer has a complete copy of the project repository, allowing them to work independently and merge changes when needed.

Key Features of Git:

  • Version Control: Track and revert changes in your project.

  • Collaboration: Multiple developers can work on the same project without conflicts.

  • Branching & Merging: Developers can create separate branches for features and merge them into the main project.

  • Offline Access: Work on your code without an internet connection.

What is GitHub?

GitHub is a web-based platform built on Git that provides a space for developers to store, manage, and share code. It enhances Git by offering a graphical interface, project management tools, and collaboration features.

Key Features of GitHub:

  • Repositories (Repos): Store your project files and history.

  • Branching & Merging: Create branches for new features and merge them after review.

  • Pull Requests: Submit code changes for review before merging.

  • Issues & Project Management: Track bugs and tasks.

  • GitHub Actions: Automate workflows like testing and deployment.

Other alternatives to GitHub include Bitbucket and Gitlab.

What is Git Bash?

Git Bash is a command-line interface (CLI) that enables interaction with Git. It is especially useful for Windows users as it provides a Unix-like terminal for executing Git commands.

Getting Started with Git and GitHub

1. Installing Git

To start using Git, you need to install it on your local machine.

You can download Git here. Ensure to choose based on your operating system.


Image description

2. Setting Up Git

Once installed, configure Git with your name and email:

git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"

This associates your commits with your identity.

3. Creating a GitHub Account

  • Go to GitHub enter the same email you configured above then click on the Sign up for GitHub button.


Image description

4. Creating a Repository on GitHub

a. Log in to GitHub.
b. Click the "+" icon and select New repository.


Image description

c. Enter a repository name, a description (optional), and choose the visibility (public or private).


Image description

d. Click Create repository.


Image description

e. After creating a repository, you are directed to this page.

Image description

5. Connecting a Local Repository to GitHub

If you have an existing project, navigate to its directory and initialize Git:

cd /path/to/your/project
git

Then, connect it to your GitHub repository:

git


Image description

6. Uploading Files to GitHub

a. Add all files to the staging area:

git

b. Commit the changes:

git commit -m "Initial commit"


Image description

c. Push to GitHub:

git


Image description

d. Your new repository will contain your initial commit, just like the screenshot below.


Image description

GitHub Flow: A Simple Workflow for Collaboration

a. Create a Branch

git checkout -b

This ensures that changes are made separately without affecting the main branch.


Image description

b. Make Commits

git add .
git commit -m "Add new feature"

Frequent commits help keep track of changes.


Image description

c. Push Your Branch to GitHub

git


Image description

d. Open a Pull Request

On GitHub, navigate to your repository and open a Pull Request (PR). Add a description and request reviews.

a. Click on the New Pull Request button

Image description

b. Select the branch you want to compare against the main branch, then click on 'Create Pull Request' button.

Image description


Image description

c. Add an appropriate description to your PR explaining the changes made in that branch, then click on the 'Create Pull Request' button.

Image description

d. You are then directed to this page, where you can review the changes and click on 'Merge Pull Request' once you're done.

Image description

e. You review before merging, ensuring all checks have passed and there are no conflicts.


Image description

f. The pull request has been successfully merged.


Image description

Advanced Git Features

1. Rebasing

Rebasing moves or combines commits to a new base, making your commit history cleaner.

git

2. Resolving Merge Conflicts

If conflicts arise when merging, Git will notify you. Open the conflicting files, make necessary changes, then:

git add .
git commit -m "Resolved merge conflict"
git

3. Forking and Contributing to Open Source

  1. Fork a repository on GitHub.

  2. Clone your forked repo:

    git
  3. Make changes and push them.

  4. Open a pull request to contribute.

Resources to Learn Git and GitHub

If you want to dive deeper into Git and GitHub, here are some helpful courses and articles:

Conclusion

Git and GitHub are powerful tools that streamline version control and collaboration. Whether you're working on personal projects or contributing to open-source, mastering Git and GitHub will significantly improve your development workflow.

🤝 Contributing

Found this helpful?
Consider sharing it with your network!
If you spot any errors or have suggestions for improvement, feel free to leave a comment below.

Happy coding! 🚀

Brand Logo

Get in touch

Fill out the form, or reach out directly. I’ll respond within 24 hours.

Or, let’s discuss

zainaboyedeji95@gmail.com

Copied

Created by

Company Logo

Cre8lab

Icon
Brand Logo

Get in touch

Fill out the form, or reach out directly. I’ll respond within 24 hours.

Or, let’s discuss

zainaboyedeji95@gmail.com

Copied

Created by

Company Logo

Cre8lab

Icon
Brand Logo

Get in touch

Fill out the form, or reach out directly. I’ll respond within 24 hours.

Or, let’s discuss

zainaboyedeji95@gmail.com

Copied

Created by

Company Logo

Cre8lab

Icon

Create a free website with Framer, the website builder loved by startups, designers and agencies.