Git Commands for DevOps Interview

🚀 Hi all, one of the most asked interview questions in DevOps & Git is: “Explain common Git commands with Daily usage.” Let’s break down some important Git commands line by line 👨💻👇 🔹 1. git init 👉 Initializes a new Git repository 📌 Used when starting a new project 💡 Creates a hidden .git folder to track changes 🔹 2. git clone <repo_url> 👉 Copies an existing repository from remote to local 📌 Example: cloning from GitHub 💡 Automatically sets remote origin 🔹 3. git status 👉 Shows current state of the repository 📌 Displays: Modified files Staged files Untracked files 🔹 4. git add <file> 👉 Adds changes to staging area 📌 Example: git add app.py 💡 Use git add . to add all files 🔹 5. git commit -m "message" 👉 Saves changes to local repository 📌 Message should be meaningful 💡 Represents a snapshot of your project 🔹 6. git push origin <branch> 👉 Uploads local commits to remote repo 📌 Example: git push origin main 💡 Used after committing changes 🔹 7. git pull 👉 Fetch + merge changes from remote 📌 Keeps your local repo updated 💡 Equivalent to git fetch + git merge 🔹 8. git branch 👉 Lists or creates branches 📌 Example: git branch feature-login 💡 Helps in parallel development 🔹 9. git checkout <branch> 👉 Switches between branches 📌 Example: git checkout main 💡 Use -b to create & switch 🔹 10. git merge <branch> 👉 Merges another branch into current branch 📌 Example: merging feature → main 💡 May cause conflicts (need resolution) 🔹 11. git log 👉 Shows commit history 📌 Useful for tracking changes 💡 Add --oneline for short view 🔹 12. git reset 👉 Undo changes (soft/hard reset) 📌 Used carefully ⚠️ 💡 Can remove commits or unstage files 🔥 If you found this helpful: 👉 Follow me for more DevOps & Cloud interview questions #DevOps #Git #Cloud #AWS #Kubernetes #InterviewPreparation #SoftwareEngineering #cloudinterviewquestions #devopsinterviewquestions #githubinterviewquestions

  • logo

This is a great cheat sheet, Syed! git status is easily my most used command—I probably run it five times before every single commit just to be safe. 😅 Thanks for sharing!

To view or add a comment, sign in

Explore content categories