DEV Community

Joseph Nganga
Joseph Nganga

Posted on

Code, Version control and Git.

Hey, in the digital era we're in today, projects have gotten complicated, and we need a place to store the code/ project, a standard procedure to track changes and improvements we make to the project. This gets even more complicated when the project is not just an individual one, but involves many developers' contributions to the project.
So, how do we track who made what change, what version of the project is the latest, what changes have been made, and what are the new updates?
Enter a version control system.
The version control system records all changes made to a file over time.
When multiple developers are involved, it allows them to work together on the same project and prevents individuals from overwriting others' work.
The most widely used version control system is called Git. It's a history of all your projects. It contains an earlier version of your project, then it records changes made to the project, records who made the changes, and the time the changes were made. While git does all this on your local machine, we can alternatively do all this on Github, a cloud-based service.

How to set up GitHub.
Create a free account on
Next, download Gitbash, a command-line module on your local pc. It is used to manipulate/ edit projects on GitHub.
Gitbash allows you to write git instructions thus directly interact with GitHub, where your projects are stored.

On your gitbash, you first set it up to connect to your github by telling it who you are, as follows:

git config --global user.name "Your Full Name"
git config --global user.email "youremail@example.com"

To confirm the details, you run the following command:

git config --global --list

We then need to link our git bash to our GitHub, using an ssh key.
on our git bash, we generate this key using:
ssh-keygen -t ed25519 -C "your_email@example.com"

We then turn the key into an agent using: eval "$(ssh-agent -s)"
command.
We then add the ssh key agent to git bash using: ssh-add ~/.ssh/id_ed25519

Creating a repository.

On your git bash, use the command 'mkdir' followed by a name to create an empty directory, and cd followed by the name to move into that directory. In this directory, you can write code. All this is done on our local pc. Therfore to push this code to GitHub, we use the command 'git add.'
This tells git to stage all changes made to your file/directory. Once the command is accepted without error, we use the command 'git commit' and add a commit message(notes or explanations). We will use this on GitHub to track changes and give explanations for what changed and why. Finally, we use the command 'git push' to push all our changes to GitHub.

Tracking changes and pulling code.

If the project has contributions from different developers, we use the command 'git pull' to download changes made on the project to our local pc
before we push, to avoid merge conflicts. This has the advantage of also showing us what changes were made to the project by other contributors using the command 'git status'

Top comments (0)