Easy steps to start using GitHub
How to use GitHub for beginners.
Mon May 01 2023 - 2 min read
GitHub is a hosting site service based on Git and is widely used by many developers for small and large projects, there are some free and paid versions. It is build for collaborative projects as a social aspect of coding and it’s owned by Microsoft.
Pull requests are one of the features that make GitHub shines, that combine a code review, where different developers propose changes to existing projects, and make the community engage.
First steps
- Create a GitHub account.
- Configure your profile.
- Choose a connection option, HTTPS requires a username and password and SSH is easier to work in a secure way.
Create an SSH key
Check keys in the root directory.
$ ls -al ~/.ssh
Generate key.
$ ssh-keygen -t ed25519 -C "email@host.com"
Accept the default location. Add a passphrase if you want extra security
> Enter passphrase (empty for no passphrase): [Type a passphrase]
Start the ssh-agent.
$ eval "$(ssh-agent -s)"
Add your SSH private key to the ssh-agent
$ ssh-add ~/.ssh/id_ed25519
Copy the public key and go to GitHub and open settings, next click on SSH and GPG Keys, add a new SSH key, give a title to identify your computer, and paste it into the key box. Click on add SSH key and enter your GitHub password.
$ cat ~/.ssh/id_ed25519.pub
In your terminal type the following code to test your connection.
$ ssh -T git@github.com
That’s it, we are now authenticated to connect by ssh with our GitHub, congratulations!
Repos
Repositories are the building blocks of GitHub, first, create a repository and clone it into your local, it can be public or private, and only collaborators can change the code.
Overview to work with GitHub and Git
git clone
- a full copy of the remote repository in the local directory.git add
- track the files.git commit
- store changes in the local directory.git push origin main
- push to GitHub. Here it could conflict if there are new changes in the remote repository (GitHub repository).git fetch
andgit merge
- to pull the most recent changes from the remote repository, orgit pull
to do both commands (git fetch
andgit merge
).
And that’s it, now you know the basics of working with GitHub.