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.
- Visit https://git-scm.com/downloads.
- Click on the correct version of your operating system. In my case, Mac OS X. The current version of Git is
2.6.4at the time of writing this post.
Open the installer
.dmgfile and install like other software installer in Mac OS X. Then you will see this dialog when done.
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.
Choose Use Git from the Windows Command Prompt like following screenshot.
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
git init command, as shown in screenshot below.
- What happening is
Gitcreated a new
.gitsubfolder which make our new folder a repo.
- 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.