Software development is all about writing code and developing solutions following requirements and processes. Managing code becomes complex with time and multiple contributors. In the real scenario, multiple developers work on the same project and write code on a daily basis. Tracking changes and merging those codes are hassle and time consuming without any proper tools or platforms. Another issue along with is roll back which is not possible without using any version control tools. When it comes to writing code, source code management is another important factor to consider. Source code management is not only just storing the code safely but also tracking the changes, resolving the conflicts, and merging from multiple contributors.
There are several tools and platforms available for source code management with exclusive features.
In this article, I will elaborate about GitHub, one of the most used, a cloud based open-source community to manage your source code plus extensive features with git repositories. In this article, I will cover the following points.
- What is Git
- What is GitHub
- What is GitHub Desktop
- Installation and Authentication of GitHub desktop
- How to create a Git repository
- Add new project in the repository
- Add existing project in the repository
- Make and Commit changes to the project
In this article, I will explain about Git, GitHub, and GitHub desktop. Furthermore, I will be doing hands-on by creating a git repository, adding a project, and doing the changes using GUI GitHub desktop.
What is Git
Git is a version control system for managing the source code which keeps the track of it with many options. Basically, it is a software to track the changes of files mostly used for coders to work collaboratively and source code management during the software development.
As per Git-SCM (https://git-scm.com/)
Git is a free and open source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.
Git is easy to learn and has a tiny footprint with lightning-fast performance. It outclasses SCM tools like Subversion, CVS, Perforce, and ClearCase with features like cheap local branching, convenient staging areas, and multiple workflows.
If you want to go in depth of Git, please check the link below.
What is GitHub
In simple terms, GitHub is a single largest cloud-based hosting service for managing git repositories which offers a wide range of functionality for source code management and version control as well as its own features. The best thing about GitHub is that it is completely free. You can create private as well public repositories with GitHub without any cost with some conditions. It is widely used to host open-source projects. As of now, GitHub free plan allows the creation of unlimited private repositories with unlimited collaborators, however there is a restriction of Git Actions up to 2000 minutes for those private repositories per month.
Along with Git, GitHub provides its own features like bug tracking, task management, code review, continuous Integration/continuous deployment, likewise other features which makes this platform more useful and interactive professionally.
You can explore more on GitHub from this link: https://docs.github.com/en
What is GitHub Desktop
GitHub desktop is an application which enables GUI based interaction with GitHub. Git provides a wide range of commands for Git activities like creating repositories, commits, pull requests and so on. However, GitHub desktop provides GUI based those activities using best practices with Git and GitHub. We can use GitHub desktop to do most of the Git commands with UI and clicks which makes collaboration and working with Git more flexible. You can connect to your account, create git repositories, add projects, do the changes, and commit easily with the interface. I will be doing hands on with GitHub desk in this article.
Know more about GitHub desktop: https://docs.github.com/en/desktop/installing-and-configuring-github-desktop/overview/getting-started-with-github-desktop
GitHub desktop is available for both windows and macOS.
Link to download GitHub desktop: https://desktop.github.com/
Installation and Authentication of GitHub desktop
This is straight forward. We can download the setup file from the above link. We can install GitHub desktop in Windows 7 64 bit or later and macOS 10.10 r later.
Step 1. Download the package based on your OS. I will demonstrate with the Windows version.
Step 2. Double click the downloaded setup file and continue the setup.
Once the setup is completed, GitHub desktop will launch.
You can authentication securely with your account and access the resources from GitHub desktop.
Open GitHub Desktop.
Click File and Options as shown above.
How to Create a Git Repository in GitHub
In this section, we will create a new Git repository in GitHub using GitHub desktop.
Click File in GitHub desktop as portrayed.
We will get an option to create a new repository which is shown. Additionally, there are other options like adding local repository, clone repository.
We will select New Repository.
Then we will get the following options for creating a Git repository.
We will enter:
Name: Name of Git Repository. In my case name is Demo-GitHub
Description: We can small description of this repository as shown
Local Path: We need to choose a local path for this repository where the actual project will be stored locally.
Initialize this repository with a README: this is an option to add a readme file. I recommend adding this file for every project as we can have details of the project, changes, versions as so on.
Git ignore: This option will add ignore to this repository. You can choose file type which you want to ignore as shown.
License: You can choose a license for this repository. I will be choosing the MIT license.
After entering those values, we will click create repository.
Once you click the create repository, we will our GitHub desktop as shown.
We can observe the following things from the UI.
- Current repository as Demo-GitHub
- Current Branch – Main
- Commit option
- Publish your repository to GitHub.
We will initiate with publish repository by click on it as shown.
After clicking on the Publish repository, we will get following options as depicted.
We will have an option to choose GitHub.com or Enterprise. Here, we are using free one, GitHub.com. We will provide following data.
- Name: This will be the name of the Git repository in GitHub.com
- Keep this code private: A checkbox is to make this Git repository private or public. I will be keeping this repository as public; therefore, I will uncheck this.
Once we click Publish repository, finally, the repository is created in GitHub as shown:
We have successfully create Git repository in GitHub using GitHub desktop. This is how we create a Git repository in GitHub using GitHub desktop application without writing any command.
Add new or existing project in the repository
This is also straight forward. We can create a new project or add existing project to our local repository location as shown:
Then local repository folder will be opened.
In this regard, I will create a new project in the same location, we can add the project to the GitHub repository. Let us create a asp.net core project in visual studio as shown.
I will use the same local repository location and check the option Place the solution and project in the same directory.
We have successfully created a demo project.
Once the project is created successfully, we go back to GitHub Desktop. We will find all the files of the above project in the changes list of GitHub desktop as illustrated.
Now we can add a comment for the changes and click commit.
I will commit this as it is. However, if you want you can uncheck files or folders which you are willing to discard the changes.
After commit, we will see the below screen to push the commits to origin remote.
We can see that 1 commit is waiting to be pushed to GitHub. Up to now, we have committed the changes to the local repository only.
Next, we will click the Push Origin to push the project to GitHub Online. Right after clicking, the GitHub desktop will start pushing to origin, GitHub.
Finally, we have added the project to GitHub and committed. We can see the project in the GitHub site as shown.
Cheers! We have successfully created a Git repository and added a project to the Git in GitHub using GitHub desktop. Here, we have used GUI based GitHub desktop for Git Actions without any command.
Similarly, we can add existing projects to the Git repository in GitHub as I have done for the new project. We can copy and paste the existing project to that location and check the changes in GitHub desktop.
Make and Commit changes to the project
Next, we will do some changes in the project files and commit the changes using GitHub Desktop. I will simply modify the index page of the project, then we will see the changes in GitHub desktop. Instantly, we will see the changes list in GitHub desktop as shown.
GitHub desktop is so intelligent that it indicates the changes as well. Isn’t it amazing?
Next, we will push to the origin.
We will push the changes to GitHub and check in GitHub.com.
The changes are committed to the repository in GitHub.
This is how we can promptly commit those changes into GitHub.com using GitHub desktop.
In this article, I have explained about source code management and version control. I have also elucidated about Git which is a software for distributed version control, and GitHub which is a cloud-based hosting service for managing Git repositories. Furthermore, I have described GitHub desktop which is a GUI based interaction with GitHub for Git Actions. Additionally, I have shown installation and authentication steps. Additionally, I have created a Git repository, added a new project in GitHub using GitHub desktop without any command. Finally, I have made some changes and committed to the Git repository in GitHub. I have performed all those actions using GitHub desktop without any command.