Everything Git Commands

Git Clone

Git Clone is used to replicate a copy of a remote repository into your local enviroment.

Git Clone "Url of your remote repository"

Git Add

This command allows git to take a snapshot of your changes into the staging area later to be committed.

Git add "filename"

Git Commit

Git commit is used to add your changes to git repository

Git commit -m "commit message"

Git Push

Git push is used to push all your local commits into your remote repository

Git Fetch and Git Pull

Git fetch is used to get the updates from your remote repository before merging them into your local repository
It is always advisable to use git fetch before merging the changes however, if you are confident about the remote changes you can use git pull to get the remote changes integrated

Git fetch origin/main
Git pull origin/main

Git Merge and Git Rebase

Git merge is used to integrate changes from one branch unto another branch. Assume you are working on a feature branch and there is an update to the main branch
You can integrate those changes from your main branch using the git merge feature

Unlike git merge git rebase creates more linear commit by applying the changes on one branch unto the other branch.
Most developers prefer the rebase as it allows for linear history. However it should be used with caution.