Basic git commands
Github is distributed version control system that is commonly used by coders/developers. By Version control, also known as source control we mean a tool to manage the software source code where usually more developers are working. The version control application keeps track of every change to the source code. If a mistake is made, developers can turn back the clock and compare earlier versions of the code to help fix the mistake while minimizing disruption to all team members. It supports non-linear development through its thousands of parallel branches.
The followings are the top version control systems that are currently being used by the largest companies to maintain their source codes.1. GitHub
2. GitLab
3. Beanstalk
4. Apache Subversion
5. AWS CodeCommit
6. Bitbucket
Every version control system has its own drawback and benefits and companies are using any of them by evaluating these as per their requirement.
Basic commands of Git
The following are some basic git commands that every developer uses in their daily coding life while working with a group of developers on the same project.
- git init
The git init command is used to create the empty repository and consider the very first command of the git.
- git pull
git pull command is used to download the content of the remote reposity. We need to apply the branch name with the git pull command like "git pull origin develop".
- git add
git add command, followed by the file name(s) or dot (.) adds a change in the working directory to the staging area. It makes the changes ready to be committed in the next commit. We can use the git add command in the following way:
a. git add file_a.php
to ad a single file
b. git add .
to add all the files
- git commit -m
The git commit -m command capture the snapshot of the project's current stash status. And the committed stage of the code is considered as a save version as well. The -m is used for the commit message. We have to add the message/description for each commit to understand the purpose of the changes. An example of this command is as below:
git commit -m "Fixing UI/UX bug on the dashboard".
- git push
This command is the opposite of the git pull command by using git push we add the local changes to the remote branch. When there are commented changes in the local working directory we need to push them to the remote branch to sync with. git push origin develop command will be used to push the changes into the develop branch
git commit --amend -m
Sometimes we type the wrong message/typo error or something else goes wrong with the commit message and we want to change it before pushing the code the following command can be used to modify it.git commit --amend -m "Your new message goes here"
Hotfix branch
A hotfix branch in Git is a branch that is created to quickly fix a problem or issue in a production environment. The branch is typically created from the production branch and is used to make the necessary changes to fix the issue. Once the changes have been made and tested, the hotfix branch is then merged back into the production branch and deployed to the live environment. This process allows for quick and efficient problem resolution without disrupting ongoing development work.