Urgent.News

What's breaking now, across thousands of outlets.

Tech

From Local Folder to Github: Setting Up my First Project With Git and Github: A Guide

Introduction Managing files locally or manually in your own pc gets out of hand very fast. You might find that you have a file named project_final_1 and project_final_2 which are about the same project but named differently depending on the day the projects were updated or modified. Git Bash is a command line tool that records detailed history of your code as it changes over time GitHub is an…

Git and Github are essential tools for managing files online. They provide a centralized location for code, enable collaboration, and allow you to maintain a history of changes. This guide will walk you through the process of setting up your first project using Git and Github.

Firstly, Git is a command line tool that records the history of your code as it changes over time. Github, on the other hand, is an online platform that stores these changes remotely. Github doesn't use folders to organize work; instead, it utilizes repositories, which make it simpler to store your work, maintain backups, and showcase your portfolio.

First, you need to install Git on your computer. This process varies depending on your operating system. After installation, you must configure Git by telling it who you are. This is done by running two commands in Git Bash: `git config --global user.name` followed by your name, and `git config --global user.email` followed by your email address. You can verify your installation by running `git --version`.

To connect your Git with Github, you need to generate an SSH key. This key allows Git to access your Github without any hassle. Run the command `ssh-keygen -t ed25519 -C` followed by your email address. When prompted, press Enter twice to save the key and to eliminate any passphrase-related issues. The public key is then copied using `cat ~/.ssh/id_ed25519.pub`.

Next, log into your Github account, click on your profile picture in the top left corner, and select 'Settings'. Then, in the left navigation bar, click on 'SSH and GPG keys'. Click the 'New SSH key' button, give a description for your key (like 'my work laptop'), select 'authentication key' as your key type, and paste your public key into the key field.

Click 'Add SSH key'. Verify the SSH connection by running `ssh -T git@github.com`. If you see the message 'Hi you have successfully authenticated, but Github does not provide shell access', you have successfully connected your Git and Github.

The next step is to create your project folder and navigate to it. Run the commands `mkdir Kenya-health-records-analysis` and `cd Kenya-health-records-analysis`. Now, add a `README.md` file and a `data` folder using `mkdir data` and `touch README.md`. Copy your `Kenya_Health_Records.csv` dataset into the `data` folder.

To stage changes that Git can track, initialize Git by running `git init`. This allows Git to track all changes made to files in the folder. Use `git status` to see which files are in your working directory but not yet staged. To stage the files, run `git add .` and confirm that the files have turned green under 'Changes to be committed'.

Finally, commit your changes with `git commit -m "initial commit"`. The `-m` flag allows you to add a message describing the changes made. Now, you're ready to connect to Github.

Create a new repository on Github by clicking the '+' icon in the top right corner and selecting 'New Repository'. Name your repository 'Kenya-health-records-analysis' and make it public. Once created, copy the repository URL provided under the 'SSH' tab.

Back in Git Bash, add the remote origin by running `git remote add origin git@github.com:PNjoroge-DataEng/Kenya-health-records-analysis.git`. This establishes the connection between your local Git repository and your Github repository. To push your code to Github, run `git push -u origin main`. The `-u` flag links the local main branch to the main branch on Github.

Written by urgent.news from Dev.to's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.

Read the original at dev.to →

More in Tech

BrunnerCTF : WordPressed to Root Writeup

Overview The box ships a mostly-stock WordPress 7.0.0 install on PHP 8.2 / Apache, running on a Debian Trixie base image, packaged as a Docker/Kubernetes challenge deployment.

More from Sunday 23 August →