Skip to content

Research About Git as a Version Management System

A. Elmacı edited this page Mar 28, 2021 · 22 revisions

What Is A Version Management System

Version management system is a practice to track and manage the changes in a set of files. This might be any type of file. If any mistake is made, the older version of the file can be brought back by just simply reverting it.

An example of a simple version management system is copying files to another directory. But you can easily make errors by copying the wrong files or copying them to wrong directory etc. To avoid these errors and to make our life much simpler there are some softwares that version the files, version control systems. This helps the user to keep track of the files in a simple manner.

An image for local versioning system:

Git : A Version Management System

Most of us have heard GitHub before but do we know how it exactly works? Why is there such a website called https://github.com/ and is it so popular? What is Git, GitHub and relationship between them? Our purpose is to answer these questions and explain you Git in more detail.

Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency as described in its website. A version control system records all the changes made to the files and enables going back and forward between these versions. It has lots of benefits which you can see below:

  • Save Time
  • Offline Working
  • Undo Mistakes
  • Track the Changes

There are a lot of version control systems such as SVN, Mercurial and Git. Git is the most popular between them. According to Stack Overflow developer survey, more than 70 percent of developers use Git, making it the most-used VCS in the world.

Advantages To Other VCS

Git has some advantages over other VCS. Some of them are:

  • The branching and merging is easy and it is encouraged in Git. The branching and merging takes seconds. Since it is very fast we can have many branches which can be role-based(testing, development, release etc.), branches for every new feature or for just experimentation.

  • It has a staging area. Which is like a buffer that the commits can be reviewed and formatted before completing the commit. This enables staging only portions of the modified files.

  • It is distributed meaning that every user clones all of the repository not just a branch. This enables that the every user has a backup of the shared repository. An image for distributed versioning system:

Setup

Configuring user information used across all local repositories

git config --global user.name “[firstname lastname]”

set a name that is identifiable for credit when review version history

git config --global user.email “[valid-email]”

set an email address that will be associated with each history marker

git config --global color.ui auto

set automatic command line coloring for Git for easy reviewing

Basic Commands

The below image is am example of the Git system. It has bunch of commits and two branches(main and stable). Main is currently being used, HEAD. Also it has a staging part. It is also will be used as a reference for the other graphs:

  • Green is for commits
  • Orange is for the branches pointing to a commit
  • Current branch is specified with HEAD

Commands

git config

Change user name or e-mail

git init

Initialize a local git repository in the current directory

git clone

Create copy of files in the given repository

git add

Add files to the staging area

git commit

Take a snapshot of project. It only takes files in staging area into consideration.

git status

Show the changed files

git push

Send changes to the connected repository

git pull

Take changes from connected repository

git branch or git branch [branch-name]

Create a new branch

git checkout

Change the current branch

git merge

Merge current branch with a different branch

git diff

View the conflicts

git log

Show commit id and information

git reset

Change current branch to another commit

Tracking Path Changes

git rm [file]

Delete the file from project and stage the removal for commit

git mv [existing-path] [new-path]

Change an existing file path and stage the move

git log --stat -M

show all commit logs with indication of any paths that moved

When git sucks

git rebase [branch]

apply any commits of current branch ahead of specified one

git reset --hard [commit]

clear staging area, rewrite working tree from specified commit

GitFlow

GitFlow is a branching model for Git, created by Vincent Driessen. It has attracted a lot of attention because it is very well suited to collaboration and scaling the development team.

References

Clone this wiki locally