Distributed Version Control System - Part 2
To Read - ๐๐ป Distributed Version Control System - Part 1 ๐๐ป
Basic Git Commands
1. Project folder แกแွแ်း Git repository แกแแ
် แแ်แီးแြแ်း
git init
2. แှိแြီးแား repository แို local machine แို copy แုแ်แြแ်း
git clone
3. แแ်แှိ file แกแြေแกแေ (modified, staged, untracked) แိုแြแ့်แြแ်း
git status
4. แြแ်แแ်แှုแျားแို commit แုแ်แို့ stage แုแ်แြแ်း
git add filename.py
git add .
5. Staged changes แို repository แှာ save แုแ်แြแ်း
git commit
6. Local repository แှ committed changes แို remote repository แို့ แို့แြแ်း
git push
7. Remote repository แှ latest changes แို local repository แို့ แူแြแ်း
git fetch origin
git pull origin main
8. Branch แျားแြแ့်แြแ်း แို့แแုแ် แกแแ
်แแ်แီးแြแ်း
# Local branches
git branch
# Remote branches
git branch -r
# All branches
git branch -a
9. Branch แแ
်แုแှ branch แแ
်แုแို့ แြောแ်းแြแ်း
git checkout <branch_name>
10. Branch แแ
်แုแဲ့ changes แို แกแြား branchแแ
်แု แှာ merge แုแ်แြแ်း
git merge <branch_name>
11. Delete Branches
# Delete merged branch
git branch -d <branch-name>
# Force delete
git branch -D <branch-name>
12. Commit History แြแ့်แြแ်း
# View commit history
git log
# Full history
git log --oneline
# Compact view
git log --graph
# See differences
git diff
13. Git Revert
git revert is a safe way to undo changes because it takes the changes from a specific commit and creates a new commit that undo the current changes. # Revert the most recent commit
git revert HEAD
# Revert a specific commit using its hash
git revert a1b2c3d4
# Revert multiple commits
git revert HEAD~3..HEAD
14. Git Reset
git reset actually removes commits from history.
git reset --soft <commit-hash> # undo but keep changes staged # Undo last commit but keep changes staged git reset --soft HEAD~1 # Reset to specific commit, keep changes staged git reset --soft a1b2c3d4
git reset --hard <commit-hash> # Completely remove # Completely remove last commit and all changes git reset --hard HEAD~1 # Reset to specific commit, lose all changes git reset --hard a1b2c3d4 # Reset to remote branch state git reset --hard origin/main
15. Conflict During Branch Merge or Conflict During Pull
# When conflicts occur during merge git merge <branch-name> OR # You try to pull but have local changes git pull origin main
# Manually edit the conflicted files: git add <resolved-file> git commit # Complete the merge # Abort merge if needed git merge --abort "Note: You don’t need to memorize all these Git commands, but learning them will help you become familiar with Git. These are just the essential commands—there are many more to explore."
✨ May ✨
23 August 2025 (23:55 BST)
Comments
Post a Comment