BEGINNER'S GUIDE TO GITHUB. SETTING UP A REPOSITORY.

Bakulumpagi Calvin
4 min readMar 22, 2021

WHAT IS GITHUB?

GitHub is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere.GitHub has essentials like repositories, branches, commits, and Pull Requests which enable a smooth flow of projects for both project leaders and other developers.

Why do we need it?

The primary benefit of GitHub is its version control system, which allows for seamless collaboration without compromising the integrity of the original project.

It makes a contribution to open source code easy.

It helps in tracking code across versions and also in tracking work. These and more are some of the reasons why we need Github as software developers.

CREATING A GITHUB ACCOUNT.

To be able to create an account you need to visit the GitHub website and fill out their registration form.

https://github.com/

When you are done creating an account with GitHub then you will have to go ahead and do some work or projects with it.

If you are using windows like I am, it would be good if you download Git bash onto your computer. Git Bash is an application for Microsoft Windows environments that provides an emulation layer for a Git command-line experience.

CREATING A REPOSITORY ON GITHUB.

Create a new repository by clicking the “new repository” button on the GitHub web page.

Pick a name for your first repository, add a small description. You can leave your repository public to enable people to be able to see your work and click “create repository” It’s a green button at the bottom

When you click the “Create repository” button it will direct you to another page where you will be able to clone your remote repository and make a local repository.

Here is when we open our Gitbash to start pushing commands that will enable us to initiate our local repository, add our remote repository, add files, commit our work and be able to push to our Github repository.

  1. we change the directory to desktop on our gitbash by typing the “cd desktop” command
  2. Then we create a folder on our desktop through gitbash by typing the “mkdir ‘foldername’ ”
  3. We then change the directory to the folder we have opened so that we can be able to work in it by typing the “cd ‘foldername’ ” Here we are also cloning the remote repository to the local repository.
  4. we then initialize the local git repository on our computer by typing the “git init” command
  5. To add files to our folder through gitbash we can use the “touch readme.md or touch aboutme.txt or touch login.css”
  6. We can also open our code editors using gitbash. For my case, I am using VS code and so I will go to my gitbash and type the “code .” command and this will have my code editor opened. In there I will be able to see the folders that I had opened earlier but they will have the letter ‘U written against them, this means they are ‘unstaged’
  7. To check the status of my files in gitbash I will type the “git status” command and this will show me my files but they will be in red to show me that I have not committed them yet.
  8. We go ahead to add our files, we can add them using the “git add .” to add all the available files.
  9. Commit the files that you’ve staged in your local repository. $ git commit -m "First commit"
  10. It is important to create branches in GitHub so that it can enable us to edit code and also other people working on the same project without necessarily altering the original code. This can be done by typing the “git branch -m main” command or “git branch ‘login’ ”
  11. In the Command prompt, add the URL for the remote repository where your local repository will be pushed. “$ git remote add origin <REMOTE_URL>
  12. Push the changes in your local repository to GitHub
$ git push origin main

CONCLUSION

After following these steps you would have successfully created an account in Github, created a repository, and cloned it to have both the local and remote repositories. You would also have managed to push your work to GitHub. However, there are more defined ways to do this same task and I encourage you to read wider on the same.

Thank you for reading.

--

--