Why all the developers using Git?

Sitharakumarasingha
4 min readMay 15, 2022

What is this Git?

Git is a version control system for tracking changes in computer files. It helps in coordinating work amongst several people in a project and tracks progress over time. Git branches, unlike centralized version control systems, can be readily merged. Every time a developer wants to start working on anything new, a new branch is formed. This guarantees that the master branch always contains code that is fit for production. Because Git is a distributed version control system, each developer has their own personal repository with complete commit history. Git is faster since it no longer requires a network connection to produce commits or run diffs between commits.

What is GitHub?

GitHub is a Git repository hosting service that provides a web-based graphical interface (GUI). It helps every team member work together on a project from anywhere, making it easy to collaborate. Project managers and developers use GitHub to collaborate, track, and update their work, keeping projects transparent and on pace. Privately, inside the team, or openly for the open-source community, the packages can be shared. It is possible to utilize and reuse packages downloaded from GitHub. GitHub keeps everyone in the team on the same page and organized. Issue and pull request locking, for example, let the team focus on the code.

Features of Git

  • Tracks history
  • Free and open source
  • Supports non-linear development
  • Creates backups
  • Scalable
  • Supports collaboration
  • Branching is easier
  • Distributed development

Let’s Start the Command

Commands in Git

  • Create Repositories

To create an empty Git repository, run the command git init.

:- git init

  • Make Changes

After validating the status of the files, the add command is used to add them to the staging area.

:- git add .

The commit command ensures that the modifications are saved to the local repository.

:- git commit -m “commit message”

The current working branch is returned by the command. The git status will display if the files are in the staging area but not committed. It will also display the phrase no changes to commit, working directory clean if there are no modifications.

:- git status

  • Parallel Development

To find out which branch the local repository is on, use the git branch command.
:- # Create a new branch
git branch <branch_name>

To bring the branches together, use the git merge command. The command merges modifications from one branch with those from another.
:- git merge <branch_name>

  • Sync Repositories

To move commits or push material from a local repository to a remote repository, use the git push command.
:- git push -u origin master

The git pull command is used to retrieve changes from a remote repository and merge them into the local repository.
:- git pull <branch_name> <remote URL>

Create, examine, and destroy connections to other repositories with the git remote command.

:- git remote add origin <address>

The command connects to a remote repository and downloads it to the machine. When working with a remote repository, it is comparable to the Git init command.

:- git clone <remote_URL>

According to my project experience, there are 10 Git commands that every developers should be familiar with.

I discussed these instructions earlier, so let me summarize them now.

  1. Git Clone = git clone <https://name-of-the-repository-link>

2. Git Branch =

-: Create New branch = git branch <branch-name>

-: To push the new branch into the remote repository = git push -u <remote> <branch-name>

-: View the branch = git branch or git branch --list

-: Delete the branch = git branch -d <branch-name>

3. Git checkout = git checkout <name-of-your-branch>

4. Git status = git status

5. Git add =

-: Add single file = git add <file>

-: Add everything at once = git add -A

6. Git commit = git commit -m "commit message"

7. Git push = git push <remote> <branch-name> if your branch is newly created, You should upload the branch in this command git push --set-upstream <remote> <name-of-your-branch> or git push -u origin <branch_name>

8. Git pull = git pull <remote>

9. Git revert = git revert

10. Git merge =

:- When you want to merge your feature branch into the dev branch, First Switch to the dev branch = git checkout dev

:- Update your Local dev branch = git fetch

:- Now merge your feature branch into dev = git merge <branch-name>

Thank you!!!

--

--