I have already discussed how to get started with Git. After you know the basics, you might want to start your projects and maybe find a suitable git repository hosting for your project online. With much confidence, I suggest you use GitHub (I already mentioned it in the reference section of the previous article). This is currently the only champion in git hosting—others, which exist, comparatively nothing. Here, I will show you, including command line examples, how you can proceed with GitHub.
Why should you use GitHub:
GitHub is a popular platform for developers to host, manage, and collaborate on code projects. It offers robust version control through Git, enabling teams to track changes, collaborate efficiently, and maintain project history. With features like pull requests, issue tracking, and integrated CI/CD, GitHub enhances development workflows. It also provides unlimited free private repositories and open-source community access. It supports secure methods like SSH keys and two-factor authentication, making it a highly reliable and secure option for modern software development.
Beginning with Github:
First, register for an account on GitHub. Note that while there are some restrictions for private repositories around GitHub deploy features (e.g. 2000 CI/CID minutes), the offering is generous enough to start with small/medium-sized projects.
Create Repository And Verify Your Identity:
Although it is possible to create a repository with a command-line argument, you won’t need this here. Go with the easier way. On your ‘Dashboard’ tab on your GitHub account, you will see an anchor link option with the text ‘Create a Repository.’ Go with it. There, you will have to enter the project name, and you may also enter a description and homepage (optional).
Now, you will have to verify your identity on GitHub to ensure that you are the right owner of the account. For that, open your computer’s ‘Git Bash’ tool and use the following commands:
$ ssh-keygen -t rsa -C "yourgithubaccountemail@domain.com"
Generating public/private rsa key pair.
Enter file in which to save the key (/current-directory-path):Enter Path Here
Enter passphrase (empty for no passphrase): Enter A Pass phrase
Enter same passphrase again: Confirm your pass phrase
Code language: PHP (php)
Remember carefully to enter only the GitHub account email, as it will identify your account using that email. Moreover, if you are in the correct directory, you can skip entering the path. You can also skip the passphrase part just by hitting enter.
After completing these steps successfully, a new file named ‘id_rsa.pub’ will be created in the directory. There you will get a key. Copy that, go to your GitHub account’s ‘Account settings’ -> ‘SSH Public Keys’ -> Add a key, then paste the key. If you see any new line appended, you may need to remove that. Otherwise, authentication may not work on later. To test, back to your ‘Git Bash,’ use the following commands:
$ ssh git@github.com
The authenticity of host 'github.com (XXX.XXX.XXX.XXX)' can't be established.
RSA key fingerprint is XX:XX:XX......
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,XXX.XXX.XXX.XXX' (RSA) to the list of known hosts.
ERROR: Hi yourname! You've successfully authenticated, but GitHub does not provide shell access
Connection to github.com closed.
Code language: PHP (php)
Starting Traditional Git Commands:
After completing the above primary stage, we are all done with the GitHub-specific works. Now, we can start using the traditional way of executing git commands that I discussed in my previous post. Just remember all the times that you are using a remote server and will need to take the extra care(commands) that a remote git server requires.
Further References:
Here, I have shown the simplest and quickest way to get things done for GitHub, but GitHub also has more detailed step-by-step instructions. Go through them if you are having some special problems. If you are still having issues, please comment here to let me know; I will try to help out my best. Happy coding 😀
Leave a Reply