Guide to Git Commands

Git is a powerful πŸ› οΈ version control system that helps developers πŸ‘©β€πŸ’» manage and track πŸ” changes to their codebase. Whether you are a πŸ†• beginner or an experienced πŸ§‘β€πŸ’» developer, understanding essential Git commands is crucial for collaboration 🀝 and efficient development.

https://youtu.be/-Jfa2qzAS-s?si=Ky0LKorS8JH5xwax

In this blog, we’ll explore key Git commands with interactive explanations 🧩 and practical examples. Let’s dive πŸŠβ€β™‚οΈ in!

1. Setting Up Git

Before you start 🏁 using Git, you need to configure your user πŸ‘€ information:

Why it matters:

These settings identify πŸ‘€ you as the author of changes πŸ”„ in your commits.

step1

2. Initializing a Git Repository

To start tracking πŸ›€οΈ a project with Git, initialize it as a repository πŸ“:

Example:

This creates a hidden πŸ•΅οΈ .git folder in your project, signaling that it’s now a Git repository.

3. Checking the Status of Your Repository

To view πŸ‘€ the current state of your repository:

πŸ€” Interactive Tip:

Run this command frequently to see which files πŸ“‚ are staged, modified ✏️, or untracked.


4. Adding Files to the Staging Area

Before committing, you need to stage changes πŸ”„:

Example:

This stages the index.html file for the next πŸ›€οΈ commit.

5. Committing Changes

Commit your staged changes πŸ”’ with a message πŸ’¬:

βœ… Best Practice:

Write ✍️ clear and concise commit messages to describe what the changes πŸ”„ do.


6. Viewing Commit History

To see πŸ‘€ a log πŸ“œ of all commits:

Example:

This shows a compact summary πŸ“ of your commit history.

7. Cloning a Repository

To copy πŸ“‹ an existing repository to your local machine πŸ–₯️:

Example:

This creates a local copy πŸ“‚ of the remote 🌐 repository.


8. Pushing Changes to a Remote Repository

To upload πŸ“€ your commits to a remote 🌐 repository:

Example:

This pushes changes to the main branch of the remote repository.

9. Pulling Changes from a Remote Repository

To update πŸ”„ your local repository with changes from the remote:

Example:

This merges remote changes into your local branch 🌿.


10. Creating and Switching Branches

Branches 🌿 allow you to work on new features independently:

Example:

This creates and switches to the feature-login branch 🌿.

11. Merging Branches

To merge changes from one branch 🌿 into another:

Example:

This merges the feature-login branch 🌿 into the current branch.


12. Resolving Merge Conflicts

Conflicts βš”οΈ occur when changes overlap. Git marks the conflict areas in your files πŸ“„:

πŸ’‘ Tip:

Carefully review πŸ‘€ conflicting changes to ensure nothing important is lost.

13. Stashing Changes

To temporarily save πŸ’Ύ changes without committing:

To apply stashed changes later πŸ•’:


14. Viewing Differences Between Commits

To see πŸ‘€ what has changed between commits:

Example:

This compares πŸ†š the latest commit with the one before it.

πŸŽ‰ Conclusion

Mastering πŸ’ͺ Git commands is essential for developers πŸ‘©β€πŸ’» to manage their code efficiently. Start 🏁 with the basics and gradually explore advanced πŸ” commands as you grow 🌱. Remember, practice makes perfect!Have questions ❓ or suggestions πŸ’‘? Drop a comment below! πŸ’¬https://academy.srtechops.com/wp-content/uploads/2025/01/Remainder-App-Technology-Logo.mp4

Devops Multi cloud Training

Choose the training style that fits your schedule β€” Self-Paced or Live Interactive Sessions. Both include hands-on projects, expert support, and lifetime access.

Feature Self-Paced Training Live Training
🎯 Mode πŸŽ₯Pre-Recorded Session πŸ§‘β€πŸ«Live Class + Recordings
πŸ’Ό Projects πŸ•’ Weekend Real-Time Projects πŸ“… Weekdays + Weekend Real-Time Projects
❓ Doubt Clearing πŸ“ž Weekend Live Support Session 🧠 Anytime Doubt Clearing Session
πŸ‘₯ Career Support & Mentorship ❌ No βœ… Yes
πŸŽ“ Global Certification Training ❌ No βœ… Yes
πŸ”‘ Access ♾️ Lifetime Access ♾️ Lifetime Access
πŸ’° Fees β‚Ή4,999 (2 x β‚Ή2,500) β‚Ή7,999 (2 x β‚Ή4,000)
ℹ️ For More Info Explore Self-Paced Training
Explore Live Training