Let’s begin with Git and GitHub
Hey Folks, I know Git and GitHub quite being complicated but give this article a read for a moment and you’ll definitely start relating things automatically.
Contended to know that you’re making efforts to learn something and this ‘something’ is really going to help you in every aspect of your journey.
Some sort of introduction-
Aren’t Git and GitHub same? Of course not, they are totally different things but yes used together to maintain a system or say a track of your record.
First let me explain GIT, so git is basically a distributed version control system. Woof, now what is version control system (VCS)? Nothing but a system that maintains different ‘versions’ of your project when we work in a team or as an individual. Here version represent as the update in your project. Also GIT is an open source tool created by Linux in 2005.
Explaining it in a furthermore, there can come a situation where we have to roll back in the past of your code or certainly from the past to current version. So copying all the data and maintaining a tons of folders, quite be ineffective, tedious and tiresome also.
So rather than goofing around, GIT was developed so all it does it that same work done above but in an astute way being combined with GitHub or any other platform.
I contemplate that, this much intro for GIT is enough and let’s move toward GitHub. From the name itself you can imagine that what is this hub of.
So here we can conclude by the upcoming statement, GitHub is a cloud-based hosting service founded in 2008 that lets you manage Git repositories. So the service is being provided on the cloud to save your ‘code’.
In 2018, GitHub was acquired by Microsoft. Afterwards the growth increased exponentially.
If you’re working on Open Source project, that uses Git, so GitHub is designed in way for programmer to manage it.
Because GitHub is so intuitive to use and its version-control tools are so useful for collaboration, nonprogrammers have also begun to use GitHub to work on document-based and multimedia projects. GitLab is an open source alternative to GitHub
Some of the features and products on GitHub which may you to acquire:-
- GitHub Desktop enables users to access GitHub from Windows or Mac desktops, rather than going to GitHub’s website.
- GitHub Pages are static webpages to host a project, pulling information directly from an individual’s or organization’s GitHub repository.
- GitHub Flow is a lightweight, branch-based workflow for regularly updated deployments.
- GitHub Gist allows GitHub users to share pieces of code or other notes.
- GitHub Student Developer Pack is a free offering of developer tools that is limited to students, and includes cloud resources, programming tools and support, and GitHub access.
Authentication has been a great deal for any organization to secure the account of individual at a personal level. It simply means that verifying the user before accessing the resource related to that.
GitHub provides a different types of authentication mentioned below:-
- Using web browser -> Various methods are included such as creating a strong password or by using Two Factor Authentication(2FA) as well attaching a security key with it increase a layer of security.
- Using API -> Here we’re including Personal Access Token. Shall be also including Web Application Flow by configuring OAuth App.
- Using Authenticator App -> We can also use app like Microsoft Authenticator which can manage your GitHub and organization account at full pace.
Hands on Practical
Here we’ll learn that how to quickly push(upload) our code on GitHub using CLI version of Git. The upcoming steps will make you confident regarding the concepts.
Step 0. Download Git CLI and create an account on GitHub. Not a very tough task to be handled.
Step 1. Install Git and then you’ll find Git Bash software installed in your PC. Just open it and you’ll see CLI popped up upon your screen.
Step 2. Create a local git repository
P.S -> Here local means your system compatible files/standalone files. Use command mkdir to make a directory.
Step 3: Get in to that directory using cd [directory_name]/
Step 4: Creating a text file or maybe some another file using command touch [filename.extension]
Step 5: Now put some content in the text file, maybe directly into the text file or using vim command. This thing is not of concerned right now.
Step 6: Now the entry of GitHub is here, open github.com and sign in using your credentials. Look for account sections and you’ll find an option for repositories.
Step 7: Click New for creating new repository.
Step 8: Creating a new private/public repository
P.S -> We’ll learn about private repository because it needs more attention. Hence Private is only visible to you and Public is for all.
Good Practice :- Always provide README file to have a proper description of your project making everyone to understand better and afterward click create repository.
Step 9: Now copy the SSH of your repository which defines the location of this project kept on the internet. You can either choose between SSH or HTTPS.
Step 10: All we have to do is to push the code(text file) over the GitHub repository. So let’s start with first step of pushing the code by using the command git init (initialize).
P.S -> .git hidden folder will be generated in your directory whose basic work is to keep the record of your changes/unchanged or un/staged file.
Step 11: Now you can check the status of your repository(local) by using the command git status.
Step 12: Now, you’ve done a lot till here so you can have a glass of water if you want. Moving ahead with next command with ‘git add .’ adding all the files to staging area.
P.S -> Note that here dot . means adding all the file for staging area if you want any particular file to be added then write git add [file_name].
Step 13: Here comes the time when we will tell the git the location of our repository on which the code is to be pushed. Using the command git remote add origin [copied_SSH].
Step 14: SET-UP ! You should now why you pushed the certain code on the repository or made changes you made with what name/issues. So to use this thing, we use git commit -m ‘initial commit’.
P.S -> Here commit means the message, -m represent that a message is being given and the text in inverted commas means what messages is given.
Step 15: Now finally we are all set to push our code on the repository. Using the command git push origin master.
Error :- Yes ! this thing will surely happen because we’re pushing our code on the remote server which is private and no one wants their private space to be edited by someone. So let’s see the solution for this.
Step 15 A: Go to the settings of your GitHub Profile by clicking the profile picture. There you’ll see that there exist an option named ‘SSH and GPG Key’.
We have to approach just that option.
Step 15 B: Click Add New SSH Key and minimize your browser window.
Go to your git bash and and generate the key using the command ssh-keygen -t rsa -b 4096 -C ‘firstname.lastname@example.org’
NOTE :- Enter file in which you want to save the key : HIT ENTER
Overwrite (y/n)? Y
Enter passphrase : HIT ENTER
Enter passphrase again : HIT ENTER
Step 15B: Now just type cat [address given in Your public key].
Step 15C: Now copy the whole key (from ssh-rsa to .com) paste it into the key section of your ADD NEW KEY and give the title as of your desire.
Step 16: Checking your connection whether you’re authenticated or not.
Just type ssh -T email@example.com. If you’re sufficient to receive a successful message then you’re done.
Step 17: Now finally and happily we can push our code on the remote server.
Type git push origin master.
Step 18: Check your file on the GitHub. It will be there with commit message given.
Adding some changes after the initial commit :-
So here, we have created one python file and edited some texts in the example.txt. So now these changes will be reflected and be checked using git status command.
So we will first add the untracked file as well modified file and commit for common.
Finally pushing the changes to the remote server.
Go to your repository and you’ll find your updated text and as well newly added .py file.
Some of the stuffs which GitHub provides :-
GitHub Student Developer Pack :- Contains a tons of developer tools and GitHub Access for students. Check it out and you’ll be amazed to get to know about their features.
GitHub Virtual Event Kit :- The Virtual Event Kit gives students like us the resources to make running online events simple and flexible.
GitHub Campus Expert :- GitHub campus expert helps students a leader among the tech evangelist. Helps in growing community and technical aspects of society.
List of some resources to learn and understand quite in a more better way:-
To learn more and deeply about the Authentication and Security, you can move your page to Auth0/docs. Auth0 is well informed documents regarding the authentication and security system using APIs.
Happy learning and keep updated !!