Git cheat sheet with some common Git commands:
Configuration
git config --globaluser.name"Your Name"- Set your name for Git commitsgit config --globaluser.email"youremail@example.com"- Set your email for Git commits
Basic Commands
git init- Initialize a new Git repositorygit clone <repository-url>- Clone a Git repository to your local machinegit add <file>- Add a file to the staging areagit commit -m "Commit message"- Commit changes to the local repositorygit status- Show the status of files in the repositorygit log- Show the commit history of the repository
Branching
git branch- Show a list of branches in the repositorygit branch <branch-name>- Create a new branch with the specified namegit checkout <branch-name>- Switch to the specified branchgit 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 configurationgit push <remote> <branch>- Push changes to a remote repositorygit pull <remote> <branch>- Pull changes from a remote repository
Undoing Changes
git reset <file>- Unstage a file from the staging areagit checkout -- <file>- Discard changes to a file in the working directorygit revert <commit>- Create a new commit that undoes the changes in the specified commitgit 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.
