Taking code to next level with Open Source (Git & Github) || Code Quality & Performance Conference
10K views
Nov 9, 2023
In this session I will be talking about OpenSource ( Git & GitHub ) from basic to advance concepts of Git & GitHub. We will be discussing about how we can gain more experience in writing code through Git & GitHub and also will talk about how we can excel our Code Quality with Git & GitHub. Conference Website: https://globaltechconferences.com/event/code-quality-performance-virtual-conference-2021/ C# Corner - Community of Software and Data Developers: https://www.c-sharpcorner.com C# Live - Dev Streaming Destination: https://csharp.live #Codequality #opensource #Git #Github
View Video Transcript
0:00
So first of all, welcome to this session that is taking your code to next level with open source, basically GitHub
0:09
So after this session, if you gain some experience or something else, you can just share your experience on Twitter or any social media by tagging me at the Poulkitzing day
0:22
And yeah, so my name is Pulkid Singh and I'm a 13 years old self-taught programmer
0:27
So I'm currently passionately contributing towards companies, open source, as well as hackthons
0:33
And currently I'm working as an author at FreeCodeCamp Hall. And even I'm one of the 162 event ambassador at Deep Learning.com
0:44
So apart from this, I have been given, you can say, sessions on basically open source only at various, you can say, conferences and etc
0:53
So it's like even I have been contributing in 50 plus communities as well as hackathons
1:01
And like you can see, I have 4 to 5 of my own communities as well, which include programmers, seniors, and group and etc
1:10
So now let us get started with our session. So basically when we talk about open source, it's something like you can say, any project or software's audio
1:23
code is made freely available and maybe you can say redistributed and modified according to the requirement of the user or maybe you can say some other folds can contribute in it so that the project's owner can gain some more features on their project right so it's like basically programmers have more control over that kind of software and can examine the code to make sure it's not doing anything you don't want it to do and
1:53
even likely fix, they all can fix the bugs as well. But what about others
1:58
It's like open sources for everyone and even though if you are someone who is from
2:05
who doesn't have any, you can say any background in tech field
2:10
even they can get started with open source and can gain very much experience as well
2:16
So like for others, you can make your own projects, blogs, etc
2:21
and make it open so and even let others to contribute in it and even make some changes in it
2:27
and yeah there are many more advantage and even in the last if possible if i get some time
2:34
i will try to include some of the programs that even open source like other open source programs
2:40
that you can take benefits from so it's like you have some other advantages like you can
2:47
you get a very large community of like-minded inspiring people and yeah you even get some
2:54
essential support and help there so basically i will be now telling you what is git and github
3:01
and by likely differentiating both of them and it's like um git and githab are one of the
3:10
platforms that majority of the developers or programmers use for getting started with over
3:17
So yeah, let's get started with it. So first of all, what is Git
3:22
So in simple words, Git is a version control system and it can be used with various tools or locally on your computer to help you track of changes in your code projects as well
3:34
And you can maybe think of like a Google Talks for code but better, right
3:41
And in the same way, GitHub is a platform for code collaboration and GitHub uses the key
3:46
GitHub uses the Git for the version control and provides you all these sorts of, you can say, awesome collaboration tool
3:53
And even likely we have got some new features in it that I would be including to take your code to next level
3:59
And apart from this, basically you can say GitHub is a cloud platform for working on your open source project
4:09
So now let us discuss why we made version control here. So like I will tell you it through an example, like while you are freelancing, you get a client and like you are developing a website
4:23
And at that moment, like you create all the things that the user wants and then he told that he or she told that he needs some other updates in it and you just do it
4:36
And after that he says that the password was better and he wants the password only
4:41
So at that moment you won't be able to get this the last version of it right so for this we have version control system
4:50
That can help you and having all the versions of your you can see
4:56
code and anything and it will help you by just not having it in one file but it will even not create other files for
5:04
version control it will have the same and it will continue versioning your code or any project
5:11
right so like collaborators can work in parallel and even merge their changes automatically
5:17
instead of manually comparing and the differences between a file right so yeah first of all
5:25
let's make an account there on GitHub so if you are a student like me I would basically
5:31
you all can go go on to this link that is education.gitab.com and if you are someone who is a
5:40
developer or something like that you can go on with getup.com and I would probably prefer to go with getup.com first because you
5:49
will need to create an account there first and then you can go with any other things. So now
5:54
let us explore GitHub here. So just let me stop my screen once and re-share it to another
6:01
screen. Just a second. I just a second. I just
6:11
it's now visible to you all can anyone give me the confirmation once yes
6:19
well it's yeah it's now visible to yeah so like this is the main website you get into once
6:26
you have logged in or signed in to the GitHub and basically now let us explore it and become
6:33
more friendly with the UI of it so first we have a pull request tab where we create pull request
6:40
for contributing in other projects. So basically pull request means something like you want to contribute in someone else project and you just change some of the codes of it and just ask for taking your code in the main project as well
7:00
And after that you can see issues tab as well. It's something like same, just like people creating issue that there is some bug in the project in the project
7:13
or something like you can say something related to it right so this is for the same and then
7:21
we have marketplace here that probably helps you and integrating some of the apps and actions so
7:28
basically GitHub actions is something I very love and it's like the best way of getting started
7:36
with automation even it's like you can go on with automation in GitHub as well so our
7:43
After that we have Explore tab where we can explore some of others projects as well
7:48
And then a search tab for searching some of the projects. And then now we have a notification tab for seeing all the notifications I have cleared the all
7:58
And then a plus sign for creating a new repository meaning a project and importing a repository
8:04
the same way. And then we have new guest organizations. So we can even create some organization and even like a new project
8:12
projects are something different from repository that I will be including here after some time
8:18
So now let us see like here we go with our profile
8:23
Once we click on this Navar we get to our profile then we have our own repositories
8:31
then code spaces which I really love and basically I guess many of you all would be like
8:37
more knowing about if you are a developer you would be used to with Vs code right
8:44
so currently I'm not having that much access on it since I just cleared the all access
8:50
since it's a you can say better better feature for right now but it would be developing
8:56
more and yeah just let's wait for some more updates in it right so at that moment you
9:02
can see like GitHub has collaborated with VS code to Wing up you something, GitHub code spaces where you can work the same like base code on the online platform and even use the Git there as well
9:20
So this is something I really love, but currently I don't have that much access to it
9:25
So yeah, let's wait for more development in it. Then we have some of the organizations
9:31
Like I'm in the part of many, so let us skip this right now
9:35
So then we come to projects. So basically when we talk about repositories, it's something like you can say your main code base and something like software
9:50
But when we come to a project, it's something like you have a project and you are using that software for creating this project
9:57
like I was currently working on some of the one and yeah it's something like even to-do list or even we have some of the other software for the same but GitHub has already included it here
10:11
so yeah that was it for knowing about this and then we have your sponsors that that's something about even you can get some sponsor from others for your project as well and then yeah like you
10:27
can even work on some of the other things I won't be getting into the other stuff since it
10:33
may leak my data so let me just get back to our main slide again so let's stop the
10:40
screenshot once re-share it and yeah it's it's now sharing yeah so now let us get started
10:53
with the developer workflow so before we get started I want to include you on
10:57
include one thing that is if you want to get started with command line interface or even
11:05
development work i would probably recommend it for getting started with like get and get up since
11:12
they if you being consistent on that platform i can probably tell that that you will you will be able to
11:23
get the understanding of how the collaboration works in a team you will be even
11:28
understanding the main command line interfaces and how the backend works and even
11:34
the worst core concepts you can even ever think right so now let us understand
11:42
the developer workflow here so first you will need to fork someone else's
11:46
code for contributing in others project like a folks is something like you
11:53
own copy of someone else repository and then you will need to create a branch the
11:57
branch is a parallel version of your copy where you will test your own changes
12:02
right so like branches as I already included making a branch allows you to
12:09
edit code without accidentally making the working version of that software so now
12:16
you will need to stage your changes as you go when you're happy with them you
12:21
will commit them and basically stage means add to cohesive or group or bundles of revisions
12:27
and commit is something like a group of revisions you want to officially add to your branch
12:32
so if you want to add your code to someone's else project you will open a pull request
12:39
and if they approve it they will merge your branch into their master branch so here
12:45
merge means to officially add the changes from your local branch in your
12:51
to the master branch or the main branch of the repository right so great and yeah like that's
12:59
how you work with git and GitHub so let us try this practically on GitHub so network activity
13:07
workflow like first of all you will need to fork the repository you want to contribute in it
13:12
like I have just given an example here and note this is only necessary if you are not a
13:19
collaborator on the project or it's your own project. It's only if you want to contribute in someone else project where you don't have the access
13:31
So now you will create a branch like something like this and etc And you should always try to name branches with your name and what you are doing So that even you can say the owners and the code maintainers can understand what you are doing there
13:47
And then open any of the file you want to contribute in it and select the edit icon that would be available to you at the right corner side
13:57
And it looks something like a pencil. So add the name of like add the code and the changes you want to maintain and then scroll to the bottom to commit the changes section and just click on it and if you want to add a descriptive message and select commit changes
14:17
Now you will return to the main page of your repo and just select pull request and because this is a simple pull request, you can simply create a pull request
14:27
if you were contributing to an open source project you would want to be very descriptive about the changes you want
14:34
since you know when you contribute in open source projects it's necessary to write the all the description of what you have made the changes etc
14:44
so that the maintainers can just understand what you have did and then they can check the changes right
14:52
and even it gives some good effect to the maintainers about you as well
14:59
So then after that, ask someone else to comment on your PR and you should also comment on someone else PR too
15:06
since it's not only about contributing in other projects but even letting others to contribute in yours, right
15:13
So you can find other pull requests by selecting the pull request tab
15:16
on the repose homepage and yeah, this is what a pull request looks like for someone
15:22
who has right access to a repo. The organizer of this workshop will likely merge the pull request and your changes would
15:32
be added in it. And like in between, it's like something common while contributing in any of the projects is
15:43
like when a file has multiple edits, right, it can be unclear which change should be committed
15:49
And this is where a conflict happens in the GitHub itself. So here I will be providing you with a conflict resolution
15:59
So for that just go to your commit you have done and just remove the code like showing with
16:08
this markdown and then you can just remove that up and then you are good to just commit
16:15
it up and it will probably most probably resolve the your conflict
16:19
And yeah, amazing. So now you know how to work with GitHub in the browser
16:24
The next section will teach you how to use GitHub on the command line on your computer
16:30
which is something really awesome. And it even includes some of the really core concepts
16:38
So, yeah. So first, once you start working on projects that are more complex
16:43
you might find that you prefer using your own local coding environment with GitHub. Right
16:49
So let's learn how to set that up and First you will need to install Git
16:54
So here when you need to contribute like open source project through Git
17:01
You will just need to install it if you have already installed you just need to check it once by typing Git dash dash
17:08
version in your terminal or any of the Terminal application So after that it should show some some output like this
17:19
If it's not something like that, then this means you don't have get installed in your device
17:26
So for that, just go to this URL, that is MLHlocal.com slash install git
17:33
And if you do not have Git installed, navigate through the URL above and just select your operating system
17:40
Basically, it's now available for macOS, Windows, Linux, as well as Unix
17:45
So open the installer and follow the instructions. It should be fine to select all of the default options
17:51
Open the installer and follow the instructions. It should be fine to select all the default options but except for the one below that you can see here
18:01
We recommend choosing a preferred text editor in this step, but yeah, it's up to you
18:07
So after that, restart your terminal or partial or Git Bash and run the command below again
18:13
So after that, it would probably show the version of... your git and this means you have installed git in your you can say device so yeah awesome
18:26
and great one so let me just check the comments section once if we have some of the
18:31
doubts in between so yeah even you all can just note down your comments like questions
18:39
and then in the last we can have for 5 to 10 minutes Q&A session as well so after this
18:46
you will need to configure Git by just entering Git config dash dashed grouper
18:52
username and then you will need to enter your username of GitHub and then same for
18:59
config your email address with the config dashed global user.email and then your email ID
19:07
So you can use the two commands below to you likely double check that you have set this up
19:13
So just enter GitConfig User. Name or GitConfiguser.Emen and it would enter up the same stuff you have given the input in the last slides, right
19:26
So now let's cover some useful commands of it. And like the workflow from the command line has few added steps compared to using GitHub
19:35
So you can clone any repository you have access to using Git clone
19:39
And then you can create a branch with grid branch, after that name of the name of the code
19:43
the branch. Now after you make changes you will use Git add to stage your changes
19:49
So basically clone means to copy a repository to your computer but not the same repository
19:55
as we talked about it in the last slides. There are some difference when we talk about Git and Geta but yeah majority are even same
20:04
So now stage means saving your changes so they are ready to be added to your branch and you
20:09
will use Git commit dash and then the comment message. to add changes to a branch and when you are ready to push your local changes to your repository you will use good push right so dash m is a flag for message that means like you can see um that means whatever comes after dash and is a message explaining your commit right so these all
20:33
practices can give you a whole bunch of experience of how how the you can say all collaboration
20:40
and deep work goes on in the practical world right so basically you you will learn something in
20:45
the practical manner to enhance your knowledge and it's something like a comment
20:49
like a comment and after that push is something like add the changes on your computer to your
20:54
GitHub repository and these are some of the key terms that helps you to understand and yeah you can
21:01
make a pull request and have your P-Hummers on GitHub like before and you can pull changes from
21:07
GitHub to your local repository as the same so you might feel a little confused by commenting
21:14
staging and pushing your changes right so let us explore a visual representation
21:19
It's probably not my desk, okay? So I just bought it through online
21:25
So, yeah. So first of all, let us talk at working directory
21:30
This is our working directory. And where the writing happens. This is something similar to coding and saving your work here
21:38
And then we have, you can say our staging area. Like when you're happy with a group of children and, like
21:45
when you're happy with your children, you just stage them there or stack them
21:49
there and like once you're done with all these stuffs here is a repository and when you're happy
21:55
with your comments or like the work you have done you commit them to the main repository so once again
22:04
this is my this is not my desk okay and here's another visual representation of what you just saw
22:11
so we have a working directory your workspace or local on your machine where you get at to staging for the staging
22:18
like for saving your draft in the staging area and once you are happy you can get
22:25
committed to the final repository and or even you can say permanent repository
22:30
so great let's try it in practical manner right so let me just check
22:37
okay okay so we were talking out first we'll need to create a repository on
22:46
get up and then work with it locally right so just go to your profile home page and just
22:51
click on click new and it will create your repository so at that moment you should just enter
22:57
your repository name that you want to add some description for it it's optional but and then
23:03
you can check the ability set up the availability of viewing public or private according to your
23:10
requirements and then you can initialize the repository with a rearme file that what i recommend
23:16
And then if you are in development area, I would recommend to have Git Ignore file and even a license
23:23
Since Git Ignore says something, that if you have some stuff that you can't share and that are private data
23:31
so DotGitignor helps you to do the same. And a license help you to don't get your, for getting your copyrights for the project
23:41
So if this were a code project, you would usually add a dot GitNor
23:46
file as I probably mentioned before and then you can create a repository by clicking on that
23:52
button that is create repository and then we will be redirect to the hint of for your new
23:58
repository so just click on clone or download and just copy the copy the URL that is
24:04
provided here as the same it would be and then click the clipboard and copy it
24:10
and back to the terminal or Git Bash and just enter Git clone and the URL that you have
24:16
and after that it would show something like cloning into repository name and etc etc
24:22
right even i can't i can't remember these things this is something not different
24:28
yeah but it's even normal i guess but yeah let us leave it and then it's important to note that
24:35
you did not simply download the code right so you cloned a Git report this means it
24:40
Git repo comes with a special folder called .Git right. So you don't need to know a lot about this folder, but just keep in mind that it connects your local project to the project on your GitHub
24:53
And this means if you delete this dot Git file, it would be something like your connection will be lost from your Git repository to the GitHub repository, meaning your local file
25:09
local files to the GitHub repository. So let's make some changes in your own project
25:16
We won't be waiting for something like just seeing what's going on, right
25:22
So note if you did not name your repo hello word, it should show something other than this and just enter CV and then your repository name
25:30
Okay, okay? Yeah, so, and like we are going to make some changes and just for now leave it
25:43
and you can do these things through some of these commands and even there are some like entering your code editor's name and it would do the same
25:53
And yeah, then you can do some stuff like this and then just to get status for seeing the status of it
26:01
and then just commit your with the first commit message and then yeah just get push for contributing in your project and in between it would show a password and it will need to configure again get a username and password so yeah just do this and while you are entering password it it won't be you can say it won't be viewable to anyone even you but even though after that you will just click or enter and it would work
26:31
So yeah, that's how it works and just select compare and pull request at your GitHub and just make the pull request there
26:39
And name your pull request appropriately, then select create full request and yeah, that's something we are likely done up with
26:49
So let us have a quick recap of it, like it is a version control system and allow you multiple people to collaborate
26:55
And GitHub adds features to Git and provides a web interface, right
26:59
and command line get lets you propose changes without the web interface
#Development Tools
#Education
#Open Source
#Programming
#Software