Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
February 22, 2023 05:06 am

Git on Windows Made Easy With GitHub Desktop


A Git GUI is a graphical user interface for using Git. It is a tool that aids developers in visualizing and executing Git operations such as fetching, pushing, cloning, merging, and the rest.


There are a few GUI clients used by Git but in this tutorial, I’ll be making use of GitHub Desktop. The purpose of GitHub Desktop is to make using Git on Windows simpler for users who are not accustomed to using the command line. Making use of GitHub Desktop allows you to utilize a graphical interface rather than the command line to carry out typical Git operations like committing changes, pushing to a remote repository, and cloning a repository. This means that you won’t need to type in commands on your terminal to be able to perform Git operations.



Downloading and Installing the GitHub Desktop


You can download and install GitHub Desktop from the official website.


GitHub Desktop HomepageGitHub Desktop HomepageGitHub Desktop Homepage

After downloading it, install and launch GitHub Desktop and connect with your GitHub account by authorizing your GitHub or signing in to your GitHub.


In a scenario where you’re not prompted to sign in to your GitHub account, don’t worry, it isn’t an issue as this can be done manually.


In the File dropdown of your GitHub desktop, select Options. A page will pop up where you can then choose the GitHub account to sign in with on the Accounts tab. Once this is done, your GitHub desktop will now be connected to your GitHub account and you’re ready to begin.


Basic Git Operations That Can be Performed on GitHub Desktop


There are some dropdowns where you can select activities you want to perform on the GitHub Desktop. You can see from the File dropdown at the top of the page, a list of options like creating a new repository, adding a local repository, and cloning a repository. There’s the Repository dropdown, with a list of options like pull, push, fetch, removing a repository, view on GitHub, and so on. There’s also the Branch dropdown with a list of options for creating a new branch, renaming a branch, merging to the current branch, deleting a branch, and so on.


Starting page - GitHub DesktopStarting page - GitHub DesktopStarting page - GitHub Desktop

1. Creating a New Repository


To create a new repository, click on the File menu, then select New repository. Give your repository a name, and choose a location on your computer where you want to store it.


Check the Initialize this repo with a readme box, leave the Git ignore and license part as the default for now, and then click Create repository


Now it has made a new repository for you as can be seen at the top left-hand corner of the page with its branch set to main by default. You can also see options to open your repo, which contains only a readme file for now, in Explorer or Visual Code or to publish it to GitHub. If you open it up in Visual Studio Code and make some changes to the readme file, save it, you will see it automatically on the GitHub Desktop repo.


Add a commit message and then commit to the main branch.


Committing to main Committing to main Committing to main

At the bottom left-hand corner, you can now input any commit message and click Commit to main. Switch to the History tab to view the history of changes and activities for that repo.


2. Publishing or Pushing a Repository to GitHub


To publish a repository to GitHub, click the Publish repository button.


Sign in to your GitHub account, if you haven’t already done so. Give your repo a name that you want to appear on your GitHub and add a description.


Leave the Keep this code private box checked if you want the repo to be private (visible only to you) but uncheck it if you want your repo to be public (visible to others). Now publish the repository. This is the same as pushing a repository to GitHub.


A View on GitHub option will appear which you can select to be able to view the repo you just published directly on your GitHub account. It will have those details like the commit message and repo description that you passed from the GitHub desktop.


View repo on GitHubView repo on GitHubView repo on GitHub

3. Making New Branches in a Repo


To create a new branch that can, later on, be merged with the main branch


Click on the Create branch tab at the top of your GitHub desktop. Press the New branch button, give your new branch a name, and create.


If you click on the Create branch tab now, you should see two branches on your repo. One is the main branch, which is the default branch and the other is the new branch you recently created.


New branchNew branchNew branch

To make changes in the new branch, select the new branch. Go to your code editor, and insert some changes in the readme.


Go back to GitHub Desktop to view the changes on the new branch, add a commit message, and then click the Commit to new button at the bottom.


Publish the new branch, wait for it to fetch the origin and you will now see that it has been published. Head over to your GitHub to see the changes on a new branch with the commit message you typed. Now you have two branches in your repository.


You can compare and pull request from either the GitHub desktop or GitHub. It’s ready to be merged to the main (master) branch now.


Merging to the main branchMerging to the main branchMerging to the main branch

Creating new branches is great for instances where you want to work on your project but you don’t want to push it to the main branch in case there’s an error that can disrupt the workflow, you can always work on a new branch, pull request and when you’re sure that it is error-free, you can then merge it with the main branch.


4. Adding an Existing Repository From the Local Machine to GitHub Desktop


Go to your file explorer and create a new folder (make sure it’s in a location where you won’t have to navigate through other subfolders to find it), and create a README file inside this folder. Now open up this folder in your code editor and type some words inside the README file, and save it.


Go to GitHub Desktop, and select the Add an existing repository from hard drive option. You get to choose the repository from a list of options. Navigate to the location where you created that folder, select the folder, and add the repository.


You’ll see a warning telling you that the folder doesn’t appear to be a Git repository and a link to create it as a new repository instead. Click Add repository.


adding an existing repoadding an existing repoadding an existing repo

Give the new repo a description, initialize it with a readme, and create.


You can work with this repo the same way as in the previous step. For example, you can open it in your code editor, making some changes to the files, and then commit the changes to main from GitHub Desktop.


Click Publish Repository to connect the local repository to the remote repository on GitHub. Changes from your local repository can now be pushed to the remote repository on GitHub.


This is basically how to add an existing local repository to GitHub Desktop and then publish it to GitHub. There is also a drag-and-drop option for adding an existing repository to GitHub Desktop. 


5. Cloning a Project


To clone a project in GitHub Desktop, follow these steps:


Open up GitHub Desktop, click on the File menu and select Clone Repository. This will pop out a prompt where you’ll be required to select a repository to clone or input the URL of the repo you intend to clone by switching from the GitHub.com tab to the URL tab.


selecting  repo to cloneselecting  repo to cloneselecting  repo to clone

Choose the local folder where you want to store the repository files or leave the default location. Click on the Clone button.


Now the repo from your GitHub account or an external one added through a repo link has been cloned in your GitHub Desktop. GitHub Desktop will download the files to your local folder. You can then start making changes and committing them back to the repository.


Conclusion


Those are just a few of the operations that can be carried out using the GitHub Desktop GUI for Git. I hope that by now, you understand how to perform Git operations on Windows using GitHub Desktop. .



Original Link: https://code.tutsplus.com/tutorials/git-on-windows-for-newbs--net-25847

Share this article:    Share on Facebook
View Full Article

TutsPlus - Code

Tuts+ is a site aimed at web developers and designers offering tutorials and articles on technologies, skills and techniques to improve how you design and build websites.

More About this Source Visit TutsPlus - Code