DEV Community

Cover image for Version Control of git/github
Kebee crc
Kebee crc

Posted on

Version Control of git/github

Git/Github
(1)What is Version Control?
When you are working on a simple project, such as a single page html, it is fairly easy to remember the last thing you changed and where the development is headed. But tracking revisions over time, also referred to as version control, quickly becomes more complex when you are working on a large project with multiple files and multiple developers.

You not only want to record changes, but also who made the changes, and when. Managing revisions at this level requires a version control system.

Version Control Systems (VCS) help a software team manage changes to source code over time.
VCS software includes tools for saving the state of a project, viewing the history of changes, and reverting changes.
Developing software without using version control is risky, similar to not having backups.

VCS can also enhance and speed up development. Depending on the version control software used, many developers can work on the same code at the same time.
For example, one developer on the team may be working on a new feature while another developer fixes an unrelated bug, each developer making their changes in several parts of the code base.

VCS even have tools to prevent conflicts when one developer's changes are incompatible with changes made at the same time by another developer.

  (2)The Git Version Control System
Enter fullscreen mode Exit fullscreen mode

One of the most popular version control systems is Git, a distributed VCS.
Git is a mature, actively maintained, open source project compatible with many operating systems and IDEs.
Git is different from other version control systems by its way of recording changes. Other systems add changes to a database, where Git records changes as a stream of snapshots.

Git has another advantage - it is distributed.
Rather than having only one single place for the full version history of a project, every developer's working copy of the code is also a repository that can contain the full history of all changes.

Git was created by Linus Torvalds in 2005 for development of the Linux kernel, with other kernel developers contributing to its initial development.

      (3)Initializing a Git Repository
Enter fullscreen mode Exit fullscreen mode

The most effective way to run Git is through a command line prompt. That means you'll be using Terminal in Mac/Linux or Command Prompt or PowerShell in Windows.

The first step to start using Git is to initialize a repository, a location for files and their revision history. Of course, this step can only be taken if you've already installed Git on your computer. There are numerous versions and ways to install Git. Which one you use will depend on your environment. Download the version that suits you from the official website.

If you want a repository in a new folder, then you will need to create a new directory (folder) and then switch to that directory. This is done at the command prompt (often indicated with $ or C:>) with the mkdir command for creating a directory and cd for navigating to a directory.

     $ mkdir my_git_project
     $ cd my_git_project
Enter fullscreen mode Exit fullscreen mode

With the commands above, a directory named my_git_project is created in the current folder and then the active directory is changed to my_git_project.

If you want to create the repository in an already existing folder, just navigate to that directory by typing cd directory_name at the command line prompt.

Once inside the appropriate folder, use the git init command to turn the directory into an empty Git repository:

 $ git init
Enter fullscreen mode Exit fullscreen mode

Top comments (0)