DEV Community

Chiiraq
Chiiraq

Posted on

GIT STARTED: A Noob's Guide To Version Control

INTRODUCTION

We might all have been there, if not, expect to be there: where, you ask??? while working on a project, we have made changes before on "perfectly working code" and as the saying goes 'if it works, don't touch it' but that is rarely the case. Code is always a balance of imperfect perfection, sometimes changes are done quite often and it is never a surety that it runs as expected to. This is where version control comes in.The first question you'll have would be what is version control??

WHAT IS VERSION CONTROL AND WHAT'S IT'S RELEVANCE ??

Version control can be defined as a system that can be utilised to track changes to files overtime, allowing you to recall specific versions of the program much later on.

It can be utilised for several different use cases including but not limited to:

  • Tracking Accountability - Shows who made what changes and when, making it easy to identify who introduced bugs or brilliant features.
  • Enables collaboration - Allows multiple people to work on the ame project simultaneously without overwriting other's changes.
  • Backup - It acts as a complete audit trail showing how your project evolves overr time. Among many other use cases.

There are endless examples of platform specific version control softwares such as gitlab, git and bitbucket but in this article i will take a keen interest in git and github. More specifically we will cover hoe to push and pull code.

HOW TO PUSH CODE TO GITHUB

You are already in flow state and have made progress on the program you are creating, a repository has already been created and all that remains is pushing your code to the platform so you can track your progress. How do you do that exactly??

  • open gitbash and on the terminal, you can use the following command:
git push origin main
Enter fullscreen mode Exit fullscreen mode
  • git push-sends commits to the remote repository
  • origin- The nickname for your Github repository
  • Main - The branch you're pushing the code to.

Once you refresh your github repository a .txt file with your project in the repositorty.

HOW TO PULL CODE FROM GITHUB

Changes may have been made to the project and you might need to retrieve the code and review. Similarly, you might be retrieving your work to continue working on a project. TO do this, follow the command:

git pull origin main
Enter fullscreen mode Exit fullscreen mode

once the the command is given the following happens:
Git fetches changes from GIthub and the changes are merged into your local code.

If the above article didn't help much, here's a video you can utilise to map your way around the terminal commands better: hope this helps

Top comments (0)