It took me to set up my Git and GitHub to realize how technology is sometimes not that straight forward at least for beginners. I mean setting up an account should be the easiest part of technology right? However Git and GitHub are packaged differently, forcing us to bear the brunt of its's convolution.
I'll break down the process to make it ingestible without intimidating a soul, because this too shall pass. Later, we will look back and be astonished of how something simple got our necks on a chokehold.
Installation
First things first, you have to set up a GitHub account on GitHub and then download git and Git Bash. I'll share a more detailed guide of this process don't worry. Git Bash is sort of the terminal that we'll use to write our commands while connecting our git to Git Bash. Git runs locally and keeps track of changes during the project while GitHub is an online version that does the same. Depending on your Operating System there are different ways to download Git. Alternatively, VS Code can be used to push your projects to GitHub and that's what we'll focus on, since its the simplest one. At this point I'm assuming we have a project that needs pushing to GitHub.
Git Configuration
This is probably the simplest part of this process after creating a GitHub account. On Git Bash, check user name user email by running
git config --global --list
If the account that exists isn't yours or you'd like to use a different one we can overwrite the existing account by using
git config --global user.name "YourGitHub Profile Name"
Then you'll be prompted to add a passphrase which is basically a password, it's advisable not to write one incase you forget it. So just *ENTER * to move to the next step.
Incase you'd like to change your branch from master to main run;
git config --global init.defaultBranch main
Key Generation using SSH
In this part we'll be generating a SSH key that we'll use to connect our Git and GitHub. SSH helps us with security because our computer needs a secure way to prove to GitHub that it is authorized to access our GitHub account
SSH stands for: Secure Shell
With SSH authentication, you create a pair of cryptographic keys.
GitHub requires the public key to be added to your account, while the corresponding private key stays on our computer. Now, this is where things a bit technical.
When we generate an SSH key, you will normally get 2 keys:
- id_ed25519 - private key
- id_ed25519.pub - Public key
But, I'd like us to generate a public key using a shortcut:
ssh-keygen -t ed25519 -C "your_email@example.com"
Then a prompt to overwrite will appear, write "y" meaning yes and press Enter. If you chose to have a password input, if you didn't press Enter then run
clip < /c/Users/user/.ssh/id_ed25519.pub to save they public key in a file.
Testing
We've already generated a key, now we use an IDE in this case VS Code to push our project to GitHub.
To confirm if we've connected our Git to GitHub using the SSH Key that we have generated. Go to Git Bash terminal and run
ssh -T git@github.com
There shouldn't be any problem with this but if anything isn't seeming right, you can always Chat GPT.
Okay now let's copy our generated key to GitHub
- Open your GitHub account
- Go to settings
- Click SSH and GPG
- Delete and add new or simply add the generated key if there are no keys yet
Using VS Code
You can create a folder or choose a folder through VS Code.
- Go to file
- Open your folder containing your project
- select your folder
Now we'll configure GitHub by;
- Clicking Source control on the left side
- Choose Manage work trust
- Initialize repository - this is the equivalent of git innit when using Git Bash
- Add change - this is a write up of the content you would like to indicate in present tense eg "Add Dataset".
- Against commit on the far right click the drop down and choose commit and sync.
From here you'll see a number of prompts, only click "Always", "Add remote", "Publish Branch", "Allow- if configuring for the first time."
Lastly, choose a browser of your choice and authorize access remembering to chose between creating a public or private key depending on your choice and preference, Sign in and viola, The project is posted on GitHub.
Something to note the name of the repository will bear the name of the folder used.
That's it imagine, there are other ways to push your projects to GitHub if that's something you are interested in , be sure to find that out, there's also a lot more to know in GitHub and GitHub Configuration but baby steps, right? That's all for today all and the best at pushing your projects on GitHub.
Top comments (0)