A Simple Guide to Using GitHub Desktop for Project Management šŸš€

Tobi OyekanmiTobi Oyekanmi
5 min read

As developers, we often work with version control systems to manage projects, especially when collaborating with teams. GitHub is a leading platform for managing code repositories, allowing us to collaborate, track changes, and manage different project versions effortlessly. This blog is an extract from my GitHub Usage Teaching Assistance class in Software Engineering, Iā€™ll walk you through the basics of using GitHub Desktop to create and manage projects. This will include creating branches, handling pull requests, and resolving merge conflictsā€”all essential Git skills!

Letā€™s dive into how you can get started with GitHub Desktop and use it to manage your projects effectively.

Why GitHub Desktop? šŸ¤”

GitHub Desktop is a user-friendly interface for interacting with GitHub repositories. It provides a simple, less intimidating environment for developers who may not be comfortable using Git via the command line. With GitHub Desktop, you can do everything from creating new repositories, committing changes, creating branches, and pushing updates to your online repository.

If you havenā€™t already, you can download GitHub Desktop here:
GitHub Desktop

Creating a New Project from GitHub Desktop

Once you've installed GitHub Desktop, letā€™s start by creating a new project.

1. Create a New Repository:

  • Open GitHub Desktop and click on the "New Repository" option.

  • Name your project, decide the repository path on your local machine, and click on Create Repository.

  • On the next window, click on Publish repository, whether you want to make the repository public or private by toggling the ā€œKeep this code privateā€ checkbox then click on Publish repository button.

The repository will now be visible on your GitHub account online, and the webpage should resemble something like this:

Syncing Local Changes with GitHub šŸŒ

Letā€™s now add some code to your repository.

2. Open the Repository in an Editor:

  • From GitHub Desktop, open the repository in your desired text editor (for example, VS Code).

  • Create a new file (e.g., app.py), add some code, and save it.

GitHub Desktop will automatically detect the changes made to the repository.

3. Committing Changes:

For each change you make, you need to commit it to GitHub to track the modification. Hereā€™s how:

  • In GitHub Desktop, youā€™ll see the updated files.

  • Add a commit message summarizing the changes made. The message should be descriptive enough to capture the essence of the update.

  • Click Commit to Main to commit the changes locally.

To reflect these changes on GitHubā€™s online repository, click the Push origin button. This ensures that the local changes are synced with GitHub.

Creating and Managing Branches šŸŒæ

In collaborative projects, branches play an important role in managing code changes without interfering with the main codebase. Letā€™s see how to create a branch and make changes safely.

4. Creating a New Branch:

  • In GitHub Desktop, click on the Branch tab, then select New Branch.

  • Name your branch (e.g., feature-save), and click Create Branch. This new branch is a copy of the main branch and can be used to develop new features safely.

5. Committing Changes to the New Branch:

Make your changes in the branch, save them, and follow the same process as beforeā€”commit your changes and push them to GitHub by clicking Publish Branch. This ensures the new branch is available online for review.

Pull Requests and Merging Branches šŸ”„

Once you've completed your work in the feature branch, you can merge it into the main branch using Pull Requests.

6. Creating a Pull Request:

A pull request (PR) allows you to propose changes to the main branch. Hereā€™s how to create one:

  • On GitHubā€™s website, go to your repository and click New Pull Request.

  • Select the branch you want to merge into the main branch (e.g., feature-save), and GitHub will compare the changes.

Since youā€™re the owner of the repository, you can approve the pull request. If youā€™re working in a team, this step would typically be handled by the project lead.

Handling Merge Conflicts āš ļø

Merge conflicts happen when two branches contain competing changes to the same lines of code. In a team, this is quite common, but itā€™s important to know how to resolve these conflicts gracefully.

7. Simulating a Conflict:

Letā€™s simulate a conflict by modifying the same file in two different branches.

  • Create a new branch called conflict, and modify the app.py file.

  • Switch back to the main branch and make another modification in app.py.

When you try to merge the conflict branch into the main branch, GitHub will raise a conflict alert.

8. Resolving Conflicts:

To resolve the conflict:

  • GitHub Desktop or your text editor will allow you to edit the conflicting code manually.

  • Decide which changes to keep, remove the conflicting lines, and save the file.

  • Commit the merge and push the changes to GitHub.

Once resolved, the changes will reflect on the GitHub website after you click the Push origin button.

Best Practices for GitHub Branches šŸ’”

Here are a few best practices when working with Git branches in collaborative projects:

  • Always create branches for new features or bug fixes. Avoid working directly on the main branch to prevent unnecessary issues.

  • Sync your branch with the main branch frequently. This ensures youā€™re always working with the latest code and minimizes conflicts.

  • Write descriptive commit messages. A well-written commit message helps others (and future you) understand what changes were made and why.

Conclusion šŸ

Using GitHub Desktop simplifies project management, especially for those new to Git. In this guide, weā€™ve covered the basics of creating projects, managing branches, making pull requests, and resolving conflicts.

Understanding how to use GitHub effectively is a key skill in software development, particularly when collaborating on teams. The more you practice, the more natural it will become, and soon youā€™ll be able to handle large projects with ease.

Happy coding! šŸ‘©ā€šŸ’»šŸ‘Øā€šŸ’»

Let me know if you have any questions or comments. You can also connect with me on GitHub or LinkedIn. Letā€™s build something awesome together!

0
Subscribe to my newsletter

Read articles from Tobi Oyekanmi directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Tobi Oyekanmi
Tobi Oyekanmi