Here's a git cheat-sheet that covers some of the most commonly used git commands:
Configuration
git config --global user.name "Your Name"
- Sets your name for all git repositories on your computer
git config --global user.email "youremail@example.com"
- Sets your email address for all git repositories on your computer
git config --global color.ui auto
Enables colored output in the terminal
Creating a repository
git init
: Initializes a new git repository in the current directory
git clone <repository_url>
: Clones an existing repository from a remote server to your local machine
Staging changes
git add <file>
: Adds a file to the staging area
git add .
: Adds all changed files in the current directory to the staging area
Committing changes
git commit -m "Commit message"
: Commits the staged changes with a message describing the changes made
Branching
git branch: Lists all local branches
git branch : Creates a new branch
git checkout : Switches to a different branch
git merge : Merges changes from the specified branch into the current branch
Remote repositories
git remote add : Adds a new remote repository
git push : Pushes changes to the specified branch in the remote repository
git pull : Pulls changes from the specified branch in the remote repository
Viewing information
git status: Shows the status of the current branch and any changed files
git log: Displays a log of all commits on the current branch
git diff: Shows the differences between the working directory and the staging area
git diff --staged: Shows the differences between the staging area and the last commit
Top comments (0)