- Set up your username and email
git config --global user.name "max-p0w3r"
- Cache your login credentials
git config --global credential.helper cache
- Initialize a repository
- Add individual file or all files to staging area ``
- Check a repository status
- Commit changes with a single line message or through an editor
git commit -m "Your short message about the commit"
- View commit history with changes
- View a particular commit
git show "ID or hash of the commit"
git show "short hash to get the same result"
- View changes before committing
- Remove tracked files from the current working tree
git rm dirname/somefile.js
git rm dirname/*.html
- Rename files
git mv dir1/somefile.js dir2
- Revert unstaged and staged changes
- Amend the most recent commit
git commit --amend -m "Updated message for the previous commit"
- Rollback last commit
- Rollback a particular commit
- Create and switch to a new branch
git branch new_branch_name
git checkout -b new_branch_name
- List all branches
- Delete a branch
git branch -d existing_branch_name
git branch -D existing_branch_name
- Merge two branches
git merge existing_branch_name
- Show commit log as graph for current or all branches
git log --graph --oneline --decorate
git log --all --graph --oneline --decorate
- Abort a conflicting merge
- Add a remote repository
git remote add awesomeapp https://github.com/someurl..
- View remote URLs
- Get additional information about a remote repository
- Push changes to a remote repository
- Pull changes from a remote repository
git pull
git pull --verbose
- Merge remote repository with local repository
- Push a new branch to a remote repository
git push -u origin new_branch
- Remove a remote branch
git push --delete origin existing_branch
- Use rebase