Creating my first GitHub project entailed use of diverse resources namely Git, GitHub, and VS Code. As the first step to creating the project, it was critical to have a deep understanding of concepts such as Git, Git Bash, GitHub, and VS Code. Without the understanding, it would have been impossible to link Git to GitHub and publish the new project.
Definition of Terms
Git and GitHub can be confusing terms, especially for beginners. While GitHub is a relatively commonplace terminology for anyone that has some level of interaction with people in the field of tech, Git is rarely mentioned. At a personal level, I had encountered the term GitHub, but never had I come across Git. As such, differentiating the two and understanding both was a crucial step in building my first GitHub project. From the onset, I learned that Git is a software program that helps one track changes in files stored in their local machine. While the software is pre-installed in some operating systems, it has to be manually installed in Windows. Git is run using Git Bash, an interface for writing Git commands. On the other hand, GitHub is cloud-based website that stores Git projects and allows collaboration among developers. Unlike Git which is local, GitHub is remote and is used to publish code created on different code editors such as VS Code.
Creating a Local Folder
Creating a local folder using Git Bash is an alternative to the traditional approach of right clicking on the screen and creating a new folder. Doing so is a step-wise procedure entailing selecting the directory within which you want to create the new folder as well as creating the new folder and the sub-folders and files within it. For my project, I created the folder on my desktop.
To list all the directories on my pc, I ran the command below in my Git Bash terminal:
ls
With Desktop being one of my directories and the directory within which I intended to create my new folder, I ran the command below to change directory to Desktop and consequently manipulate it as desired:
cd Desktop
I then created my folder christened “My-First-GitHub-Project” within Desktop by running:
mkdir My-First-GitHub-Project
Subsequently, I created 3 folders (Data, Notebook, Scripts) within “My-First-Desktop-Project” folder. This phase entailed two steps, the first one being changing directory from Desktop to “My-First-GitHub Project” folder using the command below:
cd My-First-GitHub-Project
This step was followed by creating the aforementioned folders using the Git Bash commands below:
mkdir Data
mkdir Notebook
mkdir Scripts
I also created two files within “My_First_GitHub_Project” folder using the commands below:
touch README.md
touch Analysis.py
Linking and Pushing the Project to GitHub
Linking Git to GitHub
Prior to pushing the project to GitHub, it was necessary to link Git to GitHub using the steps outlined below:
Step 1: Configuring Git
The step entailed setting up my username and GitHub email using the commands below:
git config --global user.name "My Name"
git config --global user.email “my-name@gmail.com”
Step 2: Verifying Configuration
To verify my configuration, I ran the command below:
git config --global –list
Step 3: SSH Key Generation
To generate the SSH key, I ran the command below:
ssh-keygen -t ed25519 -C “my-name@gmail.com”
The above step was followed by adding and confirming a blank passphrase. Subsequently, a public and a private key pair was generated as shown below:
id_ed25519
id_ed25519.pub
Step 4: Copying Public Key
To copy the public key, I ran the clip command with the path to where the key was stored as shown below:
clip < /c/Users/MyPC/.ssh/id_ed25519.pub
Step 5: Adding the Key to GitHub
To add the key to my GitHub account, I first logged in, then navigated to profile, then settings, then SSH and GPG Keys where I selected “New SSH Key”.
Next, I pasted the key I had copied in the “key” section and gave a brief description in the “title” section.
Step 6: Testing if The Key Was Added Properly
I then tested if the key had been added properly by going to the Git Bash terminal and typing the command below:
ssh -T git@github.com
From this command, I confirmed that the SSH connection had been established and was working properly.
Pushing to GitHub
I used VS Code to push the project created on my local PC to GitHub using the steps outlined below:
- Opened VS Code
- Clicked on “File”
- Clicked on “Open Folder”
- Selected the “My-First-GitHub-Project” folder created on my desktop
- Navigated to “Source Control” and selected “Initialize Repository”
- Wrote a “Commit Message” and then selected “Commit and Sync”
- Clicked “Publish Branch” and selected “Publish to GitHub as private repository” since I did not want the repository to be public
- Logged in to GitHub using the “Open on GitHub” button to check my newly created repository.
Overall, the whole exercise of creating my first GitHub project not only helped me conceptualize how to push a project from a local folder to GitHub but also instilled a deeper comprehension of the difference between Git and GitHub, various Git Bash commands, and how to navigate between VS Code and GitHub.
Top comments (0)