It wasn’t long ago that I too first ventured in the world of software development, a big step in my journey was discovering the version control system giant i.e. GitHub. GitHub has been a big help, as it is in any developer’s journey as they become part of digitally collaborative workspace. I remember being overwhelmed by the terms & technologies and thinking “why couldn’t we just use Google Drive instead?”, but since then it has proven to one of the most useful tools in my belt, as well as another skill to tick off in my ever developing resume.
What are version control systems and why do we use them?
Version control is the system of process of keeping track of previous versions of files throughout different phases of development. Not only is it used to keep track of different versions, but also to develop different variations concurrently. You can also restore back to a different point in time anytime you want or merge two or more versions into a single parent version. Version Control Systems eliminate the need to delete or overwrite a file every time a minor change is made or keeping track of a number of files to oversee different duplicates edited differently by various team members in your project.
If you too are thinking of becoming a part of this world, you will need a few terms to be well acquainted with to get through your journey smoothly. Below are some terms that are the cause for confusion for many young developers, but shouldn’t be:
1. Git vs GitHub
Git is a specific VCS (Version Control System). Used for keeping track of changes in source code during software development. Using git starts with installing git with comes with its own git bash terminal. All commands are given through a command terminal, having some knowledge of basic terminal commands is surely helpful. Git can be downloaded from:
GitHub is the cloud-based platform that makes collaborating using Git easier , so that changes can be seen in real time by all developers involved in the project. You need to sign up to a GitHub account to access its feature’s and link your current offline project to GitHub’s cloud storage. You can sign up using the link below:
2. What is a Repository? (How is it different from a project?)
A git repository is a master storage location for all files in a particular project. It can be though of as the project folder that contains the entirety of the files to be edited and shared. A repository can be either local (stored in your own device) or remote (stored in a different device, usually a server).
Once you have navigated to the folder that you want to use as your repository, the following command is used to initialize a repository:
Git init
Previously a repository and a project were thought to be the same thing on GitHub but fairly recently there has been a change in terms due to GitHub’s release of a new projects feature, separate from repositories. GitHub defines it as “Project boards on GitHub help you organize and prioritize your work. You can create project boards for specific feature work, comprehensive roadmaps, or even release checklists. With project boards, you have the flexibility to create customized workflows that suit your needs.”
3. Staging Files
before changes can be made in a file, it must be selected which is referred to as placing a file in the staging area. Staging a file is done through using the following command:
git add file.js
multiple files are added by separating using spaces
git add file.js file2.js file3.js
4. Cloning and Forking
One great feature of GitHub is the access to a large library of open source projects made by developers around the world. You can make a copy of an open source project on your profile by forking it. Just simply find a repository and click the fork button, a non destructive copy will be made on your personal GitHub profile.
To transfer all the source files to your computer you’ll have to clone the repository. It can be done through two ways. You can either use a clone command on your git bash terminal, or download and extract the zip file.
5. Commits and How to Write Them
On a large scale project there can be millions of changes made and logged, to keep track of who did what and when, we must add commits (timestamped descriptions of our edits) after performing each individual task so that it can be revisited and verified later by the members of a project. The command for that is:
git commit -m "your comment here"
When you first start out working it can seem tiresome to write commits after every minor edit, but believe me, it makes your job a lot easier in the long run, much like when you first develop the habit of adding comments before substantial lines of code.
6. Branches
Branches can be thought of as different timelines of a project. If you want the changes you made in the project to not overwrite the work done by your other team members, you can create a separate branch from the main branch (named Master). It way your team can work on infinitely different version of the same project without interfering with each other’s work. Cool! I know right?
7. Remotes
Connecting your local git repository to your GitHub project is done through establishing a remote. Not just anyone can upload their edits to anyone else’s repository. You need to connect your local git repository by giving it the link to the GitHub repository, you must provide your GitHub credentials, which must be verified and vetted by the owner of the repository you are uploading to.
8. Push, Pull, and Merge Requests.
After a change is made in the source files, the team members must be brought to speed to it. If you make a change locally, it must be pushed from the local Git to GitHub. It can be done using the command:
git push -u origin master
After someone else edits the source files, to update your local repository, the updated files must be pulled down to your local machine. It can be done using the command:
git pull origin master
When different projects that have deviated from each other are to be merged together. The merge command is used:
git merge <branch-name>
Closing Remarks…
I know all these terms can be a lot at first, but they are really easy to pick up on when you implement them yourselves. So get some practice while your at it and get making your own repositories my young padawans!
If you do get stuck, here are some really useful youtube videos to assist you on your journey, on Git:
on GitHub:
Top comments (0)