🎯 𝗚𝗶𝘁 𝗖𝗼𝗺𝗺𝗮𝗻𝗱𝘀 𝗬𝗼𝘂 𝗦𝗵𝗼𝘂𝗹𝗱 𝗞𝗻𝗼𝘄
📌 1. git init
This command lets us create a new .repository
A hidden .git directory is added to the folder.
Most of the git commands do not work outside the initialized project, so this is the first command you will run in a project.
Go to project folder > run git init
📌 2. git clone
This command creates a local copy of a remote repository.
When you clone a repo the source code gets automatically downloaded to the local machine.
This local repo will point to the remote repo and can PUSH and PULL changes to it.
📌 3. git add
This command add your changes to a staging area where you can compare your local version with the remote repo code.
it is mandatory to stage the code before committing (push to remote) using git add command. To stage all files use (.) — git add . iin the same repo.
📌 4. git commit
This command saves your changes to your local repository.
Every time you commit you have to add a small message about the changes you made. This will help to keep track of the changes later.
📌 5. git push
This command pushes your changes from the local repository to your remote repository. One can only push the committed changes.
It also creates the repository with the branch name you enter if the repository does not exist in the remote location.
If the branch is already connected to the remote then run — git push
📌 6. git pull
This command fetches the latest changes from the remote repository to your local.
This is helpful when multiple people are working on the same repository.
It will help to keep your local repo updated with the latest code.
If the branch is already connected to the remote then run — git pull.
📌 7. git checkout
This command helps to switch to an existing branch or create a new branch.
Before checking out make sure the branch exists in your local machine and the changes in the current branch are already staged or committed.
😊 Happy coding! 💻