Initialize a Repository:
git init
Clone a Repository:
git clone <repository_url>
Check Repository Status:
git status
Stage Changes:
git add <file_name>
Commit Changes:
git commit -m "Your commit message"
View Commit History:
git log
Create a New Branch:
git branch <branch_name>
Switch to a Branch:
git checkout <branch_name>
Merge Branches:
git merge <branch_name>
Pull Changes from a Remote Repository:
bash
git pull origin <branch_name>
Push Changes to a Remote Repository:
bash
git push origin <branch_name>
Check Differences between Branches:
bash
git diff <branch1> <branch2>
Discard Changes in Working Directory:
bash
git checkout -- <file_name>
Undo the Last Commit (Keep Changes):
bash
git reset --soft HEAD^
Undo the Last Commit (Discard Changes):
bash
git reset --hard HEAD^
Stash Changes:
bash
git stash
Apply Stashed Changes:
bash
git stash apply
Create a Tag:
bash
git tag -a <tag_name> -m "Your tag message"
Fetch Changes from a Remote Repository:
bash
git fetch origin
Remove Untracked Files:
bash
git clean -fd
Top comments (0)