DEV Community

tonny otieno
tonny otieno

Posted on

Getting started with GitHub

GitHub is a version control tool that provides software as a service used to store and track changes for an individual or a team collaborating on a project. There are also other tools for the same purpose such as Gitlab,Bitbucket that also incorporates GUI.

Setting up Git locally

  • Below is how to configure your git to connect to your remote account.
  • For linux/macOS users input the commands to your terminal while windows users after installing gitbash, will use it to write the commands. Verification is done by git config --global --list

git config --global user.name "Name"
git config --global user.email "email-address"

  1. Navigate to your local project directory and initialize git using git init .
  • Create a README.md file using touch README.mdor other files e.g a python file called users.py. The README.md file is used to tell what the project is all about and how one can use it.

Pushing Code

  • After working on your project, you have to add the changes to the staging area using git add . (for everything).
  • Commit the changes having a short message of what is committed e.g git commit -m "signup function"
  • Push your code to the remote account using git push -u origin main.

NOTE Without commiting, the changes won't be effected to the remote repository and will only remain in the local repository.First push may prompt for authentication (set up SSH keys or a Personal Access Token for HTTPS).

Pulling updated Code from GitHub

  • It is best practice to check the status of your code using git status to ensure no uncommitted changes exist. Then do a pull using git pull which is a combination of git fetch (downloads the latest commits) and git merge (merges the downloaded commits)

Top comments (0)