Git cheatsheet for beginners (Dummies)
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:
Initialize a Git repository:
git initAdding files to the repository:
git add <file_name>orgit add .to track all changes in the current directory.Committing changes:
git commit -m "commit message"Checking the status:
git statusViewing changes:
git diff <file_name>Viewing commit history:
git logUndoing changes:
git checkout -- <file_name>Creating branches:
git branch <branch_name>Switching between branches:
git checkout <branch_name>Merging branches:
git merge <branch_name>git remote This command is used to connect your local repository to the remote server.
$ git remote add [variable name] [Remote Server Link]Pushing changes to a remote repository:
git push origin <branch_name>Pulling changes from a remote repository:
git pull origin <branch_name>Cloning a repository:
git clone <repository_URL>
Note: This is just an overview of some of the most commonly used Git and GitHub commands.
