shlogg · Early preview
Clever Cottonmouth @mirajhad

Git Commands For Managing Branches And Discarding Changes

Discard uncommitted changes: `git restore .` Reset last commit: `git reset --soft HEAD~`. Delete local branch: `git branch -d branch_name`. Force delete remote branch: `git push origin --delete branch_name`.

Git to discard uncommitted changes in your working directory


git restore .


    
    

    
    




Moves the last commit back to the staging area (index), keeping all changes.


git reset --soft HEAD~


    
    

    
    




Moves the last commit back to the staging area (index), Discard all changes.


git reset --hard HEAD~

    
    

    
    




Deletes a local branch named branch_name.


git branch -d branch_name


    
    

    
    




Force Delete a Branch (If Not Merged):


git branch -D branch_name


    
    

    
    




Delete a Remote Branch:


git push origin --dele...