Git for Beginners: Complete Guide from Installation to First Push on GitHub
Git Basics: Download, Install, Create Files, Commit, and Push to GitHub
Git is a distributed version control system that helps developers track changes in source code and collaborate effectively.
In this post, you will learn everything from downloading Git on Windows to pushing your code to GitHub.
1️⃣ Download and Install Git on Windows
Follow these steps to download and install Git on a Windows machine:
Open your browser and go to:
https://git-scm.comClick Download for Windows
Run the downloaded installer
During installation:
Keep the default options
Select “Git from the command line and also from 3rd-party software”
Complete the installation
Verify Git Installation
Open Command Prompt or Git Bash and run:
2️⃣ Configure Git (Mandatory Step)
⚠️ Without configuring username and email, commits will not happen.
Verify configuration:
3️⃣ Navigate to Your Project Directory
(Adjust the path according to your system.)
4️⃣ Initialize a Git Repository
This command creates a hidden .git folder and converts the directory into a Git repository.
5️⃣ Create a File Using touch
Before tracking code, we must create a file.
This command creates an empty file named index.html.
6️⃣ Track the File Using git add
After creating the file, add it to Git tracking.
This moves the file to the staging area.
7️⃣ Commit the File
Commit the staged file to the local repository.
8️⃣ Git Workflow (CTC Model)
This is the standard Git workflow used by developers.
9️⃣ Common Git Commands
View Commit History
View Commits in One Line
View Last 2 Commits
🔟 View Changes of a Specific Commit
This shows the files and changes included in that commit.
1️⃣1️⃣ Why We Use GitHub
Developers work on their local laptops
All developers’ code needs to be combined
GitHub provides:
Centralized code storage
Collaboration
Version control
1️⃣2️⃣ Create a GitHub Repository
Create a GitHub account
Click New Repository
Enter a repository name
Click Create Repository
Note: Copy your repository URL for later use.
1️⃣3️⃣ Connect Local Repository to GitHub
Verify:
1️⃣4️⃣ Push Code to GitHub
Push your committed code to GitHub.
Authentication will open in a new browser tab.
After successful login, you will see:
1️⃣5️⃣ Important Notes
touch→ creates a filegit add→ tracks the filegit commit→ saves changes locallygit push→ uploads code to GitHub
✅ Conclusion
You have learned:
How to download and install Git on Windows
How to configure Git
How to create files using
touchHow to add, commit, and push code
How Git and GitHub work together
This is the foundation of Git and GitHub for beginners.
Comments
Post a Comment