
Configure Your Environment (done once, applies globally)
git config --global user.name "Your Name"
sets your global username
git config --global user.email "[email protected]"
sets your global email
Initialize or Clone a Project
git init
initializes a new Git repository in the current folder
git clone <repository-url>
clones a remote repository locally
Check Status & History
git status
shows changed or untracked files
git log
displays commit history
git log --oneline --graph --all
provides a condensed branch graph (handy for visualization)
Create & Switch Branches
git branch <branch-name>
creates a new branch
git checkout <branch-name>
switches to an existing branch
git checkout -b <branch-name>
creates and switches to a new branch
git branch -d <branch-name>
deletes a local branch
Commit Your Changes
git add <file>
or git add .
stages changes (a single file or all)
git commit -m "Message"
commits staged changes with a description
git commit --amend -m "New message"
updates the last commit (message or content)