Ask any veteran software developer or an HR recruiter at a successful software house and you’ll hear how there is a big gap between what students are taught in universities and what they are looking for in an employee. While academic knowledge and excellence in the core fields of Computer Science are essential, there are still a lot of things that you are not taught in school.
In Computer Science, the thing that matters the most is your passion to learn and that is exactly what employers are looking for. I have met a lot of students who, despite having a great GPA and being great students, fail to make it through even the first interview because they didn’t learn about some essential tools and/or failed to adapt to the latest technologies. Most of these students believe that having made it through school, they should have no trouble landing a good job but in this field, you need to keep learning in order to survive.
Version Control is one of the most important things all computer science graduates should be adept in and should be one of the first things taught in introductory computer science courses in Pakistani universities. In a professional environment, almost all software projects are developed through the use of a version control system.
It is not a hard thing to learn but it will make your life a lot easier when working on group projects. As a Computer Science major, I used to do share the work I did in a group project by uploading a folder on Google Drive and then giving the Share access to the other team member. Not only did was the whole process infuriatingly slow, it also meant that someone had to compile and merge all the work done concurrently. My only regret is that I didn’t find this earlier in my student life.
What is Version Control?
A Version Control system is a tool that lets a person (or a group of people) work on the same software project at the same time by managing the changes to the source code over time. It keeps a record of all the modifications which can be reverted to at any time. Think of it like an Undo button that lets you check out or roll back to any change you made.
Version Control gets rid of the annoyance of sending zip files to your peer every time you make a slight change so he or she can work on the part they are assigned to do. Moreover, it also lets you easily roll back and trace your steps after each change so you can easily detect what went wrong.
Why should you use Version Control to manage your projects?
Here are some of the biggest advantage of using Version Control,
- A complete history of every change made to every file in your project
- Branching and merging allows multiple members to work concurrently on one project
- Tracing each change and annotating code for bug fixes
Here, I’ll list down some of the basics of Version Control using Git, a free and open-source version control system that was originally created by Linus Torvalds (the creator of Linux),
Setting Up Git
Firstly, you’ll have to set up Git on your computer. Here is how you can do it,
- Head over to the download page for Git and download the installer for whatever OS you use.
- Go through the installer and follow the prompts.
Once installed, you can open up the terminal and run the following command to check if it is up and running properly,
Now, you need to set your username and email that would be used with Git on your PC. Here is how you can do it,
That’s it. You’re all set up with Git.
Making a Project with Git
Simply open the folder for your project and open Command Prompt (for Windows) or Terminal (for Mac or Linux) over there. For example, if you have a project named ‘MyProject’ on your desktop screen. Open it up and right-click to open the command prompt or Windows PowerShell for Windows or the Terminal for Mac and Linux users.
Note: A project in Git is saved in the form of a data structure called Repository.
Write the following command to initialize it as a Git Repository,
This will set up your git project.
There are a number of things you can do with Git. Here are some of the most basic commands you’ll be using the most,
This command will tell you whatever changes have been made to existing files or if any new untracked files have been added since the last commit point (in Git, a commit point is like a point when you Save a file). Whenever you make a commit, Git will record the changes you made since the last commit and establish a commit point. You can return to this commit at any time to check what state every file was in at this time.
Committing a Change
Here is how you can commit a file,
git add .
This command will add all the files to the staging area (ready to be committed).
git commit -m "a message"
This will make a commit with the message written in the quotes. It is common practice to add a message which can later be used to quickly check what changes you made in the commit.
This command can be used to get a history of all the commits you have made and all the changes made in each commit. You can also use git log —oneline to get a quick, shorter version of this command.
To learn more about how Git works and how you can use it to efficiently manage a software project, you can check out this Git Guide or go through Udacity’s free course. Git is best used with an online service like GitHub or BitBucket so that your projects can be synced across multiple computers.