DEV Community

Cover image for Understanding GitHub Workflow
Adil Shahzad
Adil Shahzad

Posted on

Understanding GitHub Workflow

Previously, we have learned how to synchronize the local git repository with the Remote GitHub Repository to store the content history of the project on GitHub. In this lesson, we will learn how you can follow the GitHub flow to easily experiment with new ideas safely without the risk of compromising the project.

What is GitHub flow?

GitHub's flow is a lightweight branch-based workflow. The GitHub workflow is helpful for everyone. With the help of GitHub flow, you can experiment on your repository.

By Default, our project is on the main branch; any changes made on the main branch will directly update the project.
When we want to experiment with new features or even fix an issue, we can create a new branch on the project. The branch will duplicate the main branch and the changes reflected in the new branch.

Creating a branch

  1. Open your repository and click the "Code" tab
  2. Click Branch: main in the drop-down
  3. In the field, enter a name for your branch (e.g., 'dev')
  4. Click Create branch.

Git Workflow

Committing a file

Now that we are on the dev branch created earlier, you can create a new file or edit the file already in the dev branch.

  1. You can add the file from the Add file, and from the dropdown, select the create new file option or edit already existing files in the dev branch.

  2. When you are done with changes, give the commit a name and description.

  3. Make sure your newly created (dev) branch is selected.

  4. Click on Commit changes.

You have made your first commit! The next step is to share the changes with your team via a pull request.

Open a Pull Request

A pull request is where we share our proposed project changes with our team — with the intent of discussing & revising them before applying the changes to the main branch.

  1. Open the Pull requests tab and click on "New pull request."

  2. In the base: dropdown menu, ensure the main branch is selected.

  3. Select the dev branch you created earlier in the compare: dropdown menu.

Delete Branch

After successfully merging the dev branch changes to the main branch, we can delete the dev branch by clicking on the delete branch button.

Summary

In this lesson, we learned the git-flow while adding features or fixing bugs in the project; with the help of git-flow, you can save your default branch and do experiments on the new branch. Practice the commands using the quiz and make sure you understand entirely Git & GitHub. You can access the Git cheat sheet, which helps you with the basic and advanced commands. When you are confident, you can go to the second module, in which we will get started with GitHub actions.

Oldest comments (0)