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

Popular posts from this blog

What Is a Design Pattern and Why Should We Use It?

Distributed Version Control System - Part 1