Git Cheat Sheet

Git is a popular version control system that allows developers to track changes to their code and collaborate with others on projects. Here is a Git cheatsheet with some common Git commands:

Basic Git Commands

git init: Initialize a new Git repository
git clone <repo>: Clone an existing Git repository
git status: View the status of your Git repository
git add <file>: Add a file to the staging area
git commit -m <message>: Commit changes to the Git repository with a commit message
git push: Push committed changes to a remote repository

Branching and Merging

git branch <branch>: Create a new branch
git checkout <branch>: Switch to a different branch
git merge <branch>: Merge changes from one branch into the current branch
git branch -d <branch>: Delete a branch

Working with Remotes

git remote -v: View the remote repositories associated with your Git repository
git remote add <remote> <url>: Add a new remote repository
git pull: Pull changes from a remote repository
git push <remote> <branch>: Push local changes to a remote repository

Undoing Changes

git reset --hard: Discard all local changes and revert to the last committed state
git revert <commit>: Revert the changes made in a specific commit
git checkout -- <file>: Discard local changes to a file and revert to the last committed version

By using these Git commands, you can manage and collaborate on code projects more effectively. This Git cheat sheet provides a useful reference for common Git operations, but there are many other Git commands and features that you can explore to further improve your workflow.