Git Cheat sheet
Initializing a new repository:
git init: Create a new local repository.
git clone /path/to/repository: Create a working copy of a local repository.
git clone username@host:/path/to/repository: For a remote server, creates a copy of the repository.
Local changes related commands:
git status: Changes in the working directory.
git diff: Changes to tracked files.
git add . or git add -A: Adds all new and changed files to the staging area.
git commit -m "Commit message": Commits changes.
git commit -a: Commits any files you've added with git add, and also commits any files you've changed since then.
Branches:
git branch: List all local branches in the current repository.
git branch [branch-name]: Create a new branch.
git checkout [branch-name]: Switch to a branch.
git merge [branch-name]: Merge a branch into the active one.
git branch -d [branch-name]: Delete a branch.
Update & Publish:
git pull: Update local repository to the newest commit.
git push origin [branch-name]: Send changes to the master branch of your remote repository.
Log:
git log: Show all commits in the current branch's history.
Stash & Clean:
git stash save: Temporarily saves all modified tracked files.
git stash pop: Restores the most recently stashed files.
git stash list: List all stashed changesets.
git clean -f: Remove untracked files.