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:

  1. Open your browser and go to:
    https://git-scm.com

  2. Click Download for Windows

  3. Run the downloaded installer

  4. During installation:

    • Keep the default options

    • Select “Git from the command line and also from 3rd-party software”

  5. Complete the installation

Verify Git Installation

Open Command Prompt or Git Bash and run:

git --version

2️⃣ Configure Git (Mandatory Step)

⚠️ Without configuring username and email, commits will not happen.

git config --global user.name "Ghouse Shaik" git config --global user.email "ghouseshaik1272@gmail.com"

Verify configuration:

git config --list

3️⃣ Navigate to Your Project Directory

cd ~/Desktop/online ls cd desktop cd online/desktop

(Adjust the path according to your system.)


4️⃣ Initialize a Git Repository

git init

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.

touch index.html

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.

git add index.html

This moves the file to the staging area.


7️⃣ Commit the File

Commit the staged file to the local repository.

git commit -m "Initial commit"

8️⃣ Git Workflow (CTC Model)

Create → Track → Commit touch → git add → git commit

This is the standard Git workflow used by developers.


9️⃣ Common Git Commands

View Commit History

git log

View Commits in One Line

git log --oneline

View Last 2 Commits

git log --oneline -2

🔟 View Changes of a Specific Commit

git show <commit_id>

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

  1. Create a GitHub account

  2. Click New Repository

  3. Enter a repository name

  4. Click Create Repository

Note: Copy your repository URL for later use.


1️⃣3️⃣ Connect Local Repository to GitHub

git remote add origin https://github.com/ghouseshaik1272/myrepo_02Jan2026.git

Verify:

git remote -v

1️⃣4️⃣ Push Code to GitHub

Push your committed code to GitHub.

git push origin master

Authentication will open in a new browser tab.
After successful login, you will see:

Authentication Succeeded

1️⃣5️⃣ Important Notes

  • touch → creates a file

  • git add → tracks the file

  • git commit → saves changes locally

  • git 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 touch

  • How to add, commit, and push code

  • How Git and GitHub work together

This is the foundation of Git and GitHub for beginners.

Comments

Popular posts from this blog

Managing Amazon EBS Volumes and Snapshots Across Regions

AWS - Amazon Web Services