Getting started with Git

Many of developers may encounter too much troubles in managing their projects files and always worrying about losing or overwriting last good working stages. Then, we tried to save ourselves from this situation by making several copies of backup by changing names outside workspace. However, we both know this can only be good for a certain time being. For long-term and large projects, we will lose traces on the project while backups taking tremendous amount of disk space on your machine.

There Git comes in, which is a powerful tool that can help you take care of your work allowing you to move around your project quickly and without friction. Git become a de facto to version source code and it is the second famous child of Linus Torvalds who forged this versioning software to keep trace of his millions of code. Some of us sometimes confuse between Git and GitHub. But it is pretty simple.

Git is the distributed version control system and it is strictly a command line tool.

GitHub is a web-based Git repository service.

Installing Git

  1. Visit https://git-scm.com/downloads.
  2. Click on the correct version of your operating system. In my case, Mac OS X. The current version of Git is 2.6.4 at the time of writing this post.
  3. Open the installer .dmg file and install like other software installer in Mac OS X. Then you will see this dialog when done. Git Installation Complete Mac OS X

  4. For Windows, there are some options should be chosen during installation. At the dialog of Select Components to install, enable Windows Explorer integration that provide you a convenient way to open a Git prompt in any folder by right-clicking on the contextual menu. Select Components Windows Git Installation

  5. Choose Use Git from the Windows Command Prompt like following screenshot. Choose Use Git from the Windows Command Prompt

  6. Use defaults for other options but these are just recommendations and you can choose other options what you prefer more. Then, At the end of process, the Git will have been installed on your Windows.

Running the first Git Command

That's it, you have successfully installed the most effective version control system on your machine and it is time to rock.
1. Simply type git in Terminal (for Mac OS X) or command prompt (for Windows), then you will see multiple available git commands.
2. Next step is to set up a new repository, named repo for short, which is a container for your entire project. In other way, every files and folder within it belongs to that repository. But it is just a folder in our local file system with a special .git folder inside created by git init command.
3. Choose a folder you like by typing cd anyfolder/you/like in Terminal. In my case I will create a new folder inside a folder named Sites under home directory. The new folder's name will be firstRepo, then the command will be cd sites/firstrepo.
4. Type git init command, as shown in screenshot below. Git init command

  1. What happening is Git created a new .git subfolder which make our new folder a repo.
  2. Then we can start putting files inside this repo and Git will trace the history of any files with the same efficiency.

I hope this would help you in getting started with Git on your project. I know this is not enough guidance for a new fresh start. So, do not miss my next post about Git fundamentals based on its repository structure and files status life cycle followed up by bundles of useful Git commands.

Nay Win Myint

A JavaScript full-stack web developer, also interested in Android application development and Graphic design.

United Kingdom