Git for Beginners – A Complete Getting Started Guide with Examples

Whether you’re a student, a new developer, or just curious about coding, Git is something you’ll hear about often. This guide is written for absolute beginners. We’ll walk you through the basics of Git, how to install it, set it up, and use it with sim…


This content originally appeared on DEV Community and was authored by Laravel Daily tips

Whether you're a student, a new developer, or just curious about coding, Git is something you’ll hear about often. This guide is written for absolute beginners. We’ll walk you through the basics of Git, how to install it, set it up, and use it with simple commands and real examples.

1. What is Git and Why Use It?

Git is a version control system (VCS). It helps developers keep track of changes in their code. If something goes wrong, Git allows you to go back to a previous version.

Why use Git?

  • Track every change in your project
  • Work with teams easily
  • Prevent accidental data loss
  • Collaborate using platforms like GitHub

2. Version Control Basics

There are two main types of version control:

  • Local VCS: Tracks changes on your computer only
  • Distributed VCS (like Git): Every developer has a full copy of the project history

With Git, every change is recorded. You can see what was changed, when, and by whom.

3. Installing Git on Windows, macOS, and Linux

Windows:

  1. Download Git from https://git-scm.com/download/win
  2. Run the installer and follow the default steps

macOS:

brew install git

(You need to have Homebrew installed)

Linux (Ubuntu/Debian):

sudo apt update
sudo apt install git

After installation, check if Git is working:

git --version

4. Setting Up Git (username, email)

Before using Git, set your name and email:

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

You can verify:

git config --list

5. Creating a Repository (git init)

A repository is like a folder that Git tracks.

mkdir my-project
cd my-project
git init

You now have a Git repository in the my-project folder.

6. Cloning a Repository (git clone)

Cloning means downloading a remote Git project to your computer.

git clone https://github.com/username/repo-name.git

7. Git File Lifecycle: Untracked → Staged → Committed

Git tracks file changes in 3 steps:

  • Untracked: New files Git doesn’t know about yet
  • Staged: Files marked to be saved
  • Committed: Files are saved in Git history

Example flow:

touch index.html                     # untracked
git add index.html                   # staged
git commit -m "Add index file"       # committed

8. Staging Changes (git add)

Use git add to tell Git which files you want to track.

git add file1.html

# To Add all files.
git add .

9. Committing Changes (git commit)

Once staged, commit your changes with a message:

git commit -m "Added homepage layout"

10. Checking Status and History (git status, git log)

To check current changes:

git status

# To see commit history:

git log

You’ll see details like author, date, and message.

11. Basic File Operations (git rm, git mv)

To delete a file from Git and your folder:

git rm unwanted.txt
git commit -m "Remove unwanted file"

To rename or move a file:

git mv oldname.txt newname.txt
git commit -m "Renamed file"

12. Creating Your First .gitignore File

The .gitignore file tells Git which files or folders to skip.

Example .gitignore:

node_modules/
.env
*.log

Create the file in your root directory:

touch .gitignore

13. 🌐 Using Git with GitHub (Basics)

GitHub is a website that stores Git repositories online. Here’s how to push your local code to GitHub:

Step 1: Create a new repository on GitHub

Step 2: Connect local project with GitHub:

git remote add origin https://github.com/yourusername/my-project.git
git branch -M main
git push -u origin main

Conclusion

Now you know the basics of Git, how it works, and how to use it daily. You’ve learned how to:

  • Set up Git on any system
  • Create and clone repositories
  • Track changes using git add and git commit
  • Work with GitHub

This is just the beginning. In the next blog, we’ll go deeper into branches, merging, and resolving conflicts.

Want more Laravel tips?

Visit LaravelDailyTips for practical guides, interview questions, and tricks.

Subscribe now and get battle-tested Laravel insights delivered to your inbox before anyone else!


This content originally appeared on DEV Community and was authored by Laravel Daily tips


Print Share Comment Cite Upload Translate Updates
APA

Laravel Daily tips | Sciencx (2025-07-30T15:32:29+00:00) Git for Beginners – A Complete Getting Started Guide with Examples. Retrieved from https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/

MLA
" » Git for Beginners – A Complete Getting Started Guide with Examples." Laravel Daily tips | Sciencx - Wednesday July 30, 2025, https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/
HARVARD
Laravel Daily tips | Sciencx Wednesday July 30, 2025 » Git for Beginners – A Complete Getting Started Guide with Examples., viewed ,<https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/>
VANCOUVER
Laravel Daily tips | Sciencx - » Git for Beginners – A Complete Getting Started Guide with Examples. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/
CHICAGO
" » Git for Beginners – A Complete Getting Started Guide with Examples." Laravel Daily tips | Sciencx - Accessed . https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/
IEEE
" » Git for Beginners – A Complete Getting Started Guide with Examples." Laravel Daily tips | Sciencx [Online]. Available: https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/. [Accessed: ]
rf:citation
» Git for Beginners – A Complete Getting Started Guide with Examples | Laravel Daily tips | Sciencx | https://www.scien.cx/2025/07/30/git-for-beginners-a-complete-getting-started-guide-with-examples/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.