Git and Github for Beginners
Source: Dev.to
What is Git and GitHub?
Git is a version control tool that tracks project files, stores the history of all changes, and logs actions taken by everyone connected to a project. It is essential for teams working on large projects that require version control and future improvements.
GitHub is an online platform that lets team members collect their individual work into a single project directory and collaborate on the combined project. (Other platforms such as GitLab and Bitbucket exist, but this guide focuses on GitHub.)
Installing Git on Windows
- Go to the Git official page and download the Windows installer.
- Run the setup file and follow the wizard, keeping the default options unless noted otherwise:
| Step | Recommended Setting |
|---|---|
| Select Components | Leave defaults |
| Default editor used by Git | Choose an installed editor (e.g., Notepad, VS Code, Sublime). If unsure, keep Notepad. |
| Initial branch name | Select main |
| Adjusting your PATH environment | Keep default |
| Choosing the SSH executable | Keep default |
| HTTPS transport backend | Native Windows Secure Channel Library |
| Line ending conversions | Windows style |
| Terminal emulator to use Git Bash | Use MinTTY |
Default behavior of git pull | Fast‑forward or merge |
| Credential helper | None |
| Extra options | Enable file system caching |
- Finish the installation and launch Git Bash.
Configuring Git
git config --global user.name "Your Name"
git config --global user.email "your.email@example.com"
Replace the placeholders with your actual name and email.
Verify the installation:
git --version
A version number should be displayed. If an error occurs, repeat the installation steps.
Creating a GitHub Account
- Visit github.com and sign up (or log in if you already have an account).
- Fill in the required details (email, password, username, country) and complete the registration.
Generating SSH Keys (Recommended)
Using SSH eliminates the need to enter your username/password for each push/pull.
ssh-keygen -t rsa -b 4096 -C "your.email@example.com"
- Press Enter to accept the default file location.
- Press Enter again for an empty passphrase (or set one if you prefer).
Copy the public key to the clipboard:
clip
The local folder now mirrors the remote repository.
Creating a New Repository from a Local Folder
If you already have a project locally and want to push it to GitHub:
cd /path/to/your/project
git init
git add .
git commit -m "Initial commit"
git remote add origin
git push -u origin main
Basic Git Commands for Collaboration
| Command | Description |
|---|---|
git pull | Fetches and merges changes from the remote repository into the current branch. |
git add . | Stages all modified and new files for the next commit. |
git commit -m "message" | Records staged changes with a descriptive message. |
git push | Sends local commits to the remote repository. |
git status | Shows the current state of the working directory and staging area. |
git log | Displays the commit history. |
Git Features Overview
- Branching & Merging – Work on isolated features without affecting the main codebase.
- Distributed Architecture – Every clone is a full backup of the repository.
- Staging Area – Fine‑grained control over which changes are included in a commit.
- Collaboration – Seamless integration with platforms like GitHub for pull requests, code reviews, and issue tracking.
- History & Revert – Complete change history enables easy rollback to previous states.
These steps provide a solid foundation for using Git and GitHub in team projects. Happy coding!