This content originally appeared on DEV Community and was authored by RaShunda Lanier
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
This content originally appeared on DEV Community and was authored by RaShunda Lanier

RaShunda Lanier | Sciencx (2024-07-11T04:30:25+00:00) GIT Cheatsheet. Retrieved from https://www.scien.cx/2024/07/11/git-cheatsheet-5/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.