top of page
Search

Welcome to Your Git Commands Guide!

  • Writer: dheeraj moolya
    dheeraj moolya
  • Oct 21, 2024
  • 2 min read

Hey there, future Git guru! 🚀 Ready to unlock the secrets of version control? Whether you're just starting out or looking to brush up on your skills, I'm here to help you navigate the world of Git commands effortlessly.


Getting Started

First things first: Installation!

If you haven’t installed Git yet, head over to git-scm.com and download it.

Set Up Your Identity:

Let’s make sure Git knows who you are. Run these commands in your terminal:

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

Essential Git Commands: Your Toolkit

Here’s a handy list of Git commands you’ll use often. Just think of them as your personal toolbox!

Command

What It Does

git init

Creates a new Git repository.

git clone [url]

Copies an existing repo from the web.

git add [file]

Prepares your changes for the next commit.

git commit -m "message"

Saves your staged changes with a note.

git status

Checks the current status of your project.

git log

Displays the history of your commits.

git branch

Lists all your branches.

git checkout [branch]

Switches to a different branch.

git merge [branch]

Combines changes from one branch into another.

git pull

Updates your local repo with changes from the remote.

git push

Sends your local changes to the remote repo.

git stash

Temporarily saves changes without committing.


Let’s Try Some Examples!

Example 1: Starting Fresh

Ready to create a new repository? Here’s how:

git init my-project
cd my-project

Example 2: Making Your First Commit

Here’s how to save your first changes:

echo "Hello, Git!" > README.md
git add README.md
git commit -m "Add README file"

Example 3: Merging Changes

Want to combine your work from different branches? Easy peasy!

git checkout main
git merge feature-branch

Common Pitfalls & Fixes

Merge Conflicts:

Uh-oh! If Git can’t figure out how to combine changes, it’ll let you know. Open the conflicting files, resolve the issues, and then stage and commit.

Detached HEAD State:

If you find yourself in a detached HEAD state, don’t panic! Just run:

git checkout main

 
 
 

Recent Posts

See All

Comments


bottom of page