Introduction
Git is a tool used to track changes made to a Git repository, while GitHub is a platform where Git repositories are stored and shared publicly or privately. In this article I will explain the procedure from a local folder to GitHub using Git and an SSH key as learnt at LuxDevHq.
1. Creating a local Folder
On Git run,
mkdir First-GitHub-Project
'mkdir' is simply 'make directory'
Basically, we're telling the computer to make a folder called 'First GitHub Project'.
Next,
cd First-GitHub-Project
'cd' simply is 'Change directory'
We're basically moving into the folder created.
2. Creating a README File
A README file gives you the freedom to edit changes to the file created.
'touch README.md'
'touch' is used to create a new empty file with extensions such as '.md' or '.py'.
3. Configuring Our laptop
git --config global user.name 'Your username'
git --config global user.email 'Your email'
Configuration prepares our laptop for all the data work ahead.
4. Generate an SSH Key
An SSH key is a secure way for a laptop to connect to one's GitHub account without repeatedly using a password.
ssh-keygen -t ed25519 -C "your email"
An SSH key will be generated that you'll copy to your clipboard.
5. Connecting Github and Git
Open GitHub, Profile picture → Settings → SSH and GPG keys → New SSH key, give it a title, paste it in the box and save it.
Next,
We test our connection to
ssh -T git@github.com
If the connection is successful, a message of successful authentication will be displayed.
6. Connecting your Git project to GitHub
On Git, run the following commands consecutively:
git init to initialise a git repo
git status to check the repo
git add . to stage our file
git commit -m "write the commit message"
git log --oneline to display the commit message on one line
git branch to confirm if you are in the main branch
git branch -M main to change from master to main branch
Open Github and
- Create a new repository
- Go to the repository's quick setup and click on SSH
- Copy the URL provide
Back on Git, run the following commands consecutively:
git remote add origin "paste the copied URL"
git remote -v
git push -u origin main
Enter a passphrase as prompted
Back to GitHub, refresh your page, and you'll be able to see the folder created displayed.
Conclusion
Coding is very interesting. The joy and thrill one feels when the Enter key is pressed and everything is running smoothly are incomparable. This data journey is an interesting one, and I'm looking forward to learning more and documenting the skills learnt in such articles.
Top comments (0)