Git Workflow Explained in 4 Stages

🚀 Git Workflow Explained Clearly – 4 Stages Sharing practical knowledge on Git Workflow in a simple way. Many people use commands like git add, git commit, and git push, but knowing what happens behind the scenes makes Git easier to learn and use confidently. 💡 Git mainly works in 4 stages, and each stage has file states every developer should know. 🔹 1️⃣ Working Directory / Working Tree Your project folder where files are created, edited, renamed, or deleted. 👉 Common file states: ✅ Untracked Files – New files created by you, but Git has not started tracking them yet. ✅ Tracked Files – Files already known to Git from previous commits. ✅ Modified Files – Tracked files that were changed after the last commit. ✅ Deleted Files – Tracked files removed from the folder. 📌 Command: git status 📌 Note: Changes exist only in your system. Nothing saved in Git history yet. 🔹 2️⃣ Staging Area / Index Place where selected changes are prepared for the next commit. Review area before saving permanently. 👉 Common terms: ✅ Staged Changes – Files added using git add and ready for commit. ✅ Partially Staged Changes – Only selected changes from a file are staged. 📌 Commands: git add filename → Add one file git add . → Add all files git restore --staged filename → Remove from staging 📌 Note: Only staged changes go into next commit. 🔹 3️⃣ Local Repository Git’s local database where commits are stored. 👉 Important terms: ✅ Commit – A saved version of your project changes. ✅ HEAD – Points to the latest commit in your current branch. ✅ Branch – A separate line of development such as main, dev, or feature. ✅ Commit History – Record of all previous commits. 📌 Commands: git commit -m "Added login page" git log 📌 Note: Changes are saved locally, not shared online yet. 🔹 4️⃣ Remote Repository Online repository like GitHub, GitLab, or Bitbucket. Used for backup and collaboration. 👉 Common terms: ✅ origin – Default remote repository name. ✅ Push – Upload local commits to remote repository. ✅ Pull – Download latest changes from remote repository. ✅ Fetch – Check updates from remote without merging. ✅ Clone – Copy remote repository to your local system. 📌 Commands: git push origin main git pull origin main git clone <repo-url> 📌 Note: This is where teams collaborate securely. 💼 Real-Time Example A developer creates a new file called login.html 1️⃣ File starts as Untracked 2️⃣ git add login.html → becomes Staged 3️⃣ git commit -m "Added login page" → saved locally 4️⃣ git push origin main → uploaded to remote repository This is the same workflow used in real projects every day. #Git #GitHub #DevOps #VersionControl #LearningGit #Developers #Automation #CareerGrowth #TechCommunity

  • graphical user interface, application

To view or add a comment, sign in

Explore content categories