Git cheat sheet with some common Git commands:

Configuration

Basic Commands

  • git init - Initialize a new Git repository

  • git clone <repository-url> - Clone a Git repository to your local machine

  • git add <file> - Add a file to the staging area

  • git commit -m "Commit message" - Commit changes to the local repository

  • git status - Show the status of files in the repository

  • git log - Show the commit history of the repository

Branching

  • git branch - Show a list of branches in the repository

  • git branch <branch-name> - Create a new branch with the specified name

  • git checkout <branch-name> - Switch to the specified branch

  • git merge <branch-name> - Merge the specified branch into the current branch

Remote Repositories

  • git remote add <name> <url> - Add a new remote repository to your local Git configuration

  • git push <remote> <branch> - Push changes to a remote repository

  • git pull <remote> <branch> - Pull changes from a remote repository

Undoing Changes

  • git reset <file> - Unstage a file from the staging area

  • git checkout -- <file> - Discard changes to a file in the working directory

  • git revert <commit> - Create a new commit that undoes the changes in the specified commit

  • git reset --hard <commit> - Reset the repository to the specified commit, discarding all changes after that commit

This is just a basic list of common Git commands. There are many other commands and options available in Git.