My FeedDiscussionsHeadless CMS
New
Sign in
Log inSign up
Learn more about Hashnode Headless CMSHashnode Headless CMS
Collaborate seamlessly with Hashnode Headless CMS for Enterprise.
Upgrade ✨Learn more

Git Techniques

Abdulmatin Adeniji's photo
Abdulmatin Adeniji
·Aug 12, 2020·

2 min read

Git is a distributed version control system to track changes in source code during software development. So if you are on a team of developers or programmer, you will need to learn a version control to help you coordinate your work and track the changes made. Git is the most used version while Github is the most used version control software. Github is a cloud-based git repository hosting service. Its used to store and manage your code.

Git Techniques to Learn for Easy Usage.

Git cloning: The first step on a git repository is to clone the codebase into your local system. This enables you to work on your copy of the repository without any interference from other changes.

To clone a repository, run the git clone

command, followed by the path to the repository which you can copy after creating a repository on github.

Branching In Git: A branch is movable pointer where commits a made into. After creating a repo, you have the master branch and other branches can be created. The advantage of Git over other version control systems is the power of its branches. To check a list of branches and the current active branch, run the following command:

git branch To create a new branch, run the following command: git branch new_branch

Even though Git creates a new branch, notice that your active branch is still the old one. To start development in a new branch, run the following:

git checkout new_branch. new_branch is the name of the new branch created.

Adding files To Git Repo: After cloning a Git repo, you will need to a files to it. To add files to your Git repo, you will need to go into the directory or folder where the files you want to add are, run the following command: git add file_name

This is if you are adding just one files to the repository. To add multiple files, run the following command: git add . This will add all the files in that folder to the Git repository.