Essential Git Commands
These are the main Git commands you will use.
git --version
Checks if Git is installed
git init
Turns your current folder into a Git repository
git status
Shows which files have been changed or added
git add filename
Adds one file to the staging area
git add .
Adds all changed files to the staging area
git commit -m "message"
Saves your staged changes with a short description
git log
Shows the full history of commits
git log --oneline
Shows a shorter and easier-to-read commit history
git diff
Shows what has changed since your last commit
git branch
Shows all branches and which one you are currently using
git switch -c branch-name
Creates a new branch and switches to it
git switch branch-name
Moves you onto another branch
git merge branch-name
Combines another branch into your current branch
git clone repository-url
Downloads an existing GitHub or GitLab repository
git pull
Downloads the newest changes from the remote repository
git push
Uploads your commits to GitHub or GitLab
The basic Git workflow is:
git status
git add .
git commit -m "Describe your change"
git push