Introduction
Data is captured in almost every aspects of our lives and it is recorded somewhere. It is important to analyse this data and transform the same to useful information which will be used for decision making. For this reason, I have realized it is important to have the right knowledge and tools to transform data into useful information and also present the same in a manner decision makers can understand.
This article will explain step by step my first git hub project by creating a local folder, transferring the same to Github and sharing the same. The tools i will employ in my work include Git, Gitbash/template, Github among others.
Git helps me track changes made in projects while Github helps one to share the project online.
Understanding Git
Its very important to understand what is git and its importance in coming up with my project.
Git will be able to help me track changes i make in my process of coming up with the project. It will clearly show me what i did and at what particular stage of my processes. This will be able to help me correct or make better the various version i have in my project. It keeps a history of all the changes i will have made in the project.
Understanding Github
Just as the name suggest, Git and Github seems to be relates but they entirely do different functions in my project. Github is an online platform that allows one to store projects and share the same online. It allows one to have a public option and a private option when it comes to storing and sharing your project.
For example; when I am working on my project in my computer, I will be able to push it to my Github account and from there, I can be able to work on it and also share with others.
1. Creating a Local Folder
Here I will clearly explain the tools I will employ to create and access my local project folder.
Below are some important codes I will use to create and access folders;
-
mkdirThis will make directory -
cdThis means change directory -
cd ..This takes you back to previous directory -
lsThis lists down whats in the directory -
rmThis deletes document in the directory -
rm -rThis deletes the folder in the directory -
touchThis creates a document
In my computer, i will create a local folder using the command mkdir my-first-github-project
NB: We are using hyphen when naming our folder to avoid spaces in between names and make the item easier to read and also follows common project naming convention. Though even without the hyphens the folder will still work.
2. Creating Folder and a README Document in my Local Folder
The next step is to create a folder with the title date and also create a README document.
Why is it important to create a data file seperately from a README document?
It makes your project organized. Instead of puting everything in one folder, its important to seperate things according to their purpose.
The Data file is used to store the actual data files while README document is a well detailed explanation and manual instruction of your project.
You will use the command
mkdir datato create a new folder called data.Use command
lsto list whats is inside my-first-github-project.
Since you have created a folder by the name data, you will only see the folder when you list.Use the command
touch README.mdto create a REAMDE document.Then use command
lsto list whats inside my-first-github-project folder. Now you will be able to see that you have the folder by the name data and a README document.
NB. Its important to name your README.md document with capital letters. This is a widely acceptable and conventional way of naming a README file. It makes the file easily recognizable and Github recognizes it automatically.
The extension md in your REAMDE.md file means that it uses Markdown language.
3. Adding content in your README.md file
Its important to clearly explain or give instruction for your project. This will be clearly documented in your README.md file.
This can be done using VS Code or Terminal/Gitbash.
- Using bash or terminal, access the folder
cd My-first-github-projectTo write content in your README.md file, we shall use the commandecho "My-first-Github-Project" >README.mdTo check what you wrote, use the commandcat README.md
We can also use Nano to simplify our writing task. We shall run the command nano README.md. A text editor will appear wherein we shall type our content.
To Save our content, we shall press Control + O to save, Press Enter Key to confirm the file, then press Control + X to exit.
NB: To check what you have written, use the command cat README.md
4. Create a Git Repository
We need to convert the ordinary file we are working in to a Git Project. We shall use the coomand git init. This creates a hidden .Git directory which contains information that our Git uses to track the developments.
After running git init command, our folder becomes a Git Repository.
5. Copying the Document With the Data to our Data folder
Since we need to work on some data, we shall transfer the data to our Data Folder.
Assume we have downloaded an excel from internet and thus is lying in our local machine download folder, I shall copy the document from the Downloads file and copy to my data file.
Alternatively, I can use the following command to copy the document to my data folder.
cp ~/Downloads/Kenyan-Health-Records-Analysis-File.xlx data/. Assume that the file was an excel file having the name Kenyan-Health-Records-Analysis.
6. Check the Status of the File
It is important to check the status of the file. You will run Git status to check the status of the file.
You will be able to see that Git has found the project file but is not tracking them.
7. Allow Git to Track the File
The next action is to let Git to track the file. This is possible by running the command Git add .
This means that Git will start tracking everything in the folder.
8. Commit Your Work
This creates a saved version of your project. Its a very important step of the project as it saves the version of the project and can allow one to track changes made in the project.
The command used to commit your work is git commit -m "Version 1 Add Kenyan Health records"
NB The wordings Version 1 Add Kenyan Health Records is tailored to your own understanding to help you know what exactly u saved at that particular stage. You can message anything provided it will help you understand what you did at that particular stage.
9. Connecting to Github
Now that we have saved our project, we now connect to Github.
Its important to run comman Git status to confirm everything is clean. You will get a message nothing to commit, working tree clean
After confirming everything is okay
- Log in to Your Github Account
- Create a repository
- Give the repository a name
10. Creating an SSH key
An SSH key is important as it gives your computer as safer way to connect to your Github account without the need to inputting password everytime when you need to work on your project.
I can check in my computer whether there it has an existing SSH Key. I will use the following command to check ls -al ~/.ssh. If you see in your computer file such as
- id_ed25519
- id_ed25519.pub It means your computer already has a key. But in cases where you dont have a key, You will be required to create one. I will describe in details what is required when generating an SSH Key.
- Generating an SSH Key
Open your Git bash/terminal and key in the following command
ssh-keygen -t ed25519 -C "your-email@example.com"Put your email and replace with the wordings your-email@example.com. - Enter the File in which you want to save the key
- Copy your public Key
- Add the public key in Github
- Under Key, paste the Public key you just created
- Add the SSH Key
- Test the connection
11. Connecting Your Local Project to Github
After successfully creating my Github repository and setting up SSH key, I will now tey connect my local Project to Github.
I will run the following command git remote add origin git@github.com:YOUR-USERNAME/kenya-hospital-records-analysis.git
NB: Replace your **YOUR-USERNAME with your user name appearing in Github.
Use the command 'git remote -v' to check the connection.
Once you confirm the connection was successful, I will now push my project to Github.
Use the command git push -u origin main.
Afterwards, refresh the page in github and you will be able to see your project.
Conclusion
The entire process has helped me understand the tools used and commands to adopt in order to push my project from a local folder to Github using SSH. The process might be lengthy at first but when you clearly understand the reason and importance of the codes being used, the process becomes clear well organized. There are sections your Gitbash/Terminal will give you errors and when you successfully correct the errors, you learn why the system behaved in such a manner and it becomes an additional learning point.
Top comments (0)