Skip to main content

Command Palette

Search for a command to run...

Git cheatsheet for beginners (Dummies)

Published
2 min read

what is Git?

  • Git is a free and open-source distributed version control system designed to handle everything from small to large projects with speed and efficiency.

  • In software development, version control systems are used to keep track of changes made to the source code, allowing multiple developers to work on the same codebase without interfering with each other.

Difference between Git and GitHub?

Git is a version control system that let us manage and keep track of source code history. GitHub is a cloud-based hosting service that let us manage Git repositories.


Git commands

setting up username and email

$ git config --global user.name "your name"
$ git config --global user.email "example@gmail.com"

Check if username and email got added

$ git config --global user.name
$ git config --global user.email

Git commands for beginners:

  1. Initialize a Git repository: git init

  2. Adding files to the repository: git add <file_name> or git add . to track all changes in the current directory.

  3. Committing changes: git commit -m "commit message"

  4. Checking the status: git status

  5. Viewing changes: git diff <file_name>

  6. Viewing commit history: git log

  7. Undoing changes: git checkout -- <file_name>

  8. Creating branches: git branch <branch_name>

  9. Switching between branches: git checkout <branch_name>

  10. Merging branches: git merge <branch_name>

  11. git remote This command is used to connect your local repository to the remote server. $ git remote add [variable name] [Remote Server Link]

  12. Pushing changes to a remote repository: git push origin <branch_name>

  13. Pulling changes from a remote repository: git pull origin <branch_name>

  14. Cloning a repository: git clone <repository_URL>

Note: This is just an overview of some of the most commonly used Git and GitHub commands.