Git and Github for Rookies
Shamal Lakshan

Using GitHub Desktop: A Beginner’s Guide to Git and GitHub

Version control systems like Git have become an essential tool for developers to manage and collaborate on projects effectively. However, for newcomers, the command-line interface of Git can be intimidating. That’s where GitHub Desktop comes in handy – a user-friendly graphical interface that makes it easier to work with Git and GitHub repositories.

What is Git?

Git is a distributed version control system that allows you to track changes in your code, collaborate with others, and manage different versions of your project. It’s a powerful tool that helps developers maintain a clear and organized coding workflow.

What is GitHub?

GitHub is a web-based hosting service for Git repositories. It provides a centralized platform for developers to store, share, and collaborate on projects. GitHub also offers additional features like issue tracking, pull requests, and project management tools.

Setting up GitHub Desktop

  1. Download and Install GitHub Desktop: Head over to the GitHub Desktop website and download the latest version for your operating system.

  2. Sign in with your GitHub Account: After installation, launch GitHub Desktop and sign in with your GitHub account credentials. If you don’t have a GitHub account yet, you can create one for free.

  3. Configure Git: GitHub Desktop will automatically detect your Git installation. If it doesn’t, you’ll need to manually configure the path to your Git executable.

Creating a New Repository

  1. Click the “Create a New Repository” button: This will open a new window where you can configure your repository settings.

  2. Choose a Name and Local Path: Give your repository a name and select a local path on your computer where you want the repository to be stored.

  3. Initialize with a README: It’s a good practice to initialize your repository with a README file, which serves as a brief description of your project.

  4. Create Repository: Click the “Create Repository” button to finalize the process.

Cloning an Existing Repository

If you want to work on an existing repository, you can clone it to your local machine:

  1. Copy the Repository URL: Navigate to the repository on GitHub and click the “Code” button. Copy the URL shown in the dropdown.

  2. Open GitHub Desktop: In the “Repository” section, click the “Clone a repository from the Internet” option.

  3. Paste the URL and Choose a Local Path: Paste the repository URL you copied earlier, and select a local path where you want to store the cloned repository.

  4. Clone Repository: Click the “Clone” button to download the repository to your local machine.

Committing and Pushing Changes

After making changes to your code, you’ll need to commit and push those changes to the remote repository on GitHub:

  1. Select the Changes: In the “Changes” section of GitHub Desktop, you’ll see a list of files you’ve modified, along with a diff view of the changes.

  2. Write a Commit Message: In the “Summary” field, write a brief description of the changes you’ve made. You can also provide a more detailed explanation in the “Description” field below.

  3. Commit Changes: Click the “Commit to main” button to commit your changes to your local repository.

  4. Push Changes to GitHub: Once you’ve committed your changes, you can push them to the remote repository on GitHub by clicking the “Push origin” button in the top-right corner.

Pulling the Latest Changes

If you’re collaborating on a project with others, it’s essential to keep your local repository up-to-date with the latest changes from the remote repository. GitHub Desktop makes this process easy:

  1. Click the “Pull origin” button: This will fetch the latest commits from the remote repository and merge them into your local repository.

  2. Resolve Conflicts (if any): If there are any merge conflicts, GitHub Desktop will highlight them, and you’ll need to resolve them manually before you can complete the pull.

By using GitHub Desktop, you can enjoy the power of Git and GitHub without the steep learning curve of the command-line interface. It provides a user-friendly way to manage your projects, track changes, and collaborate with others. As you gain more experience, you can explore the advanced features of Git and GitHub to further enhance your development workflow.