CodeX
Published in

CodeX

Fundamentals of Git

Photo of a macbook laptop on a white table, with code written on the screen
Photo by Clément Hélardot on Unsplash

Git is a popular version control system among programmers and developers. Although it’s not a programming language, it can look equally complicated to someone from a non-coding background. This article reviews fundamental concepts of Git. Then when you’re ready, you can start learning more in-depth about Git and Git commands suitable for your projects.

What is Version Control?

Imagine that you’re creating something in Photoshop. You save it as project_final.psd. You get feedback from a client or otherwise see something you want to change, but you like the current version also. You save the new file as project_final2.psd. There are more changes to be made, but you like some parts of this file that you also want to keep. So, you do a “Save As…” and make another file named project_final3.psd. This continues until your most recent file is titled something along the lines of project_finalfinalfinal6_clientapproved10.psd. Version control helps organize this type of scenario.

Version control is a system that takes memory screenshots of your files at any selected place in time you choose. After you make changes to your file, you can tell Git to “stage” or track the file to be saved. When you make “commits” or save a file in its current state, Git takes a memory screenshot of that file.

Why use a Version Control System?

Version control systems not only help maintain your project history; it also makes collaboration easier. Version control helps manage how different people are making changes to files. When Git is used with a remote repository, multiple people can access, read, and edit those files.

What is a Repository?

A repository is a virtual directory of folders and files for your project. It contains the current versions of your files, including all versions and change histories. You can create a local repository on your computer with Git, and then “push” the project to a remote repository like Github.

It is important to note that local and remote repositories may not always be in sync. That will be discussed later.

Four Commonly Used Git Commands

There are four Git commands that are commonly used: Unstage, Stage, Commit, and Push.

Unstage

Unstage means a file or set of files whose changes are not tracked by Git. This will most likely be your working project on your local repository. You may be editing a file or cloned project. Generally, these are changes that have not been committed, or saved, by Git.

Stage

When you Stage a file, it generally means that changes have been made to the file and it is ready for commit or save. You use the git add command to tell Git to track your file for commit. It’s like the QA process in getting the stamp of approval to proceed to the next step.

Commit

In an oversimplified definition, to commit a file means to save your file. You use the git commit command to commit your file.

Push

After your file is committed and you want to send your project to your remote repository, you want to push your project. You use git push to send your project from your local repository to remote repository.

After you’ve made your changes in your files in the Unstage state, then after review and reaching a good save point, you Stage them to be committed. After they are staged to be tracked by Git, you Commit or save those files as a memory screenshot in its current state. After being committed, you can Push your project from your local repository to remote repository to share with others.

Why should we use Git?

Git is one of the most used version control systems. The key element of Git is to enable collaboration. As projects in technology continue to develop, so do their expansive requirements. These projects then need to be sustained by various expertise from different fields, like in documentation and media. Git can be a useful tool in organizing collaboration among people and teams for growing projects.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store