advertisement
Branching in GitHub
Branches are a GitHub mechanism designed to allow users to create features, fix issues, or explore further development within their repository. When a user creates a repository with content on GitHub.com, the repository has a single (autogenerated) branch. This first branch in the repository is the default branch. The default branch is the one that others see when they visit that repository. This is also the initial branch that Git will check out locally when someone clones that repository. The default branch of a repository is the base branch for any new pull requests and code commits. GitHub names the default branch as the main in any new repository. This can be modified by the user to a name of his/her choice. A repository can have multiple other branches. Developers can merge a branch into another branch through a pull request.
To create a branch in a newly created repository, the user must navigate to the master branch. Then, click the drop-down menu on top which reads 'branch: master'.
Viewing Branches
Following are steps to view in a repository:
- The user should navigate to the main page of the repository on GitHub.
- Then, above the list of files, click Number branches, where Number indicates the current number of branches existing in the repository.
Navigate to any of these four lists of branches:
- Your branches: Displays all branches that you have pushed to in repositories for which you have to push access, excluding the default branch. The most recent branches are displayed first.
- Active branches: Shows all branches that anyone has committed to within the last three months. The list is ordered by branches with the most recent commits displayed first.
- Stale branches: Shows all branches that no one has committed to in the last three months, in other words, inactive branches. This list is ordered by the branches with the oldest commits first. This is useful in determining branches to be deleted.
- All branches: Shows the default branch, which is then followed by all other branches, ordered by the branches with the most recent commits first.
Deleting Branches:
Following are steps to delete branches that are no longer required:
- The user should navigate to the main page of the repository on GitHub.
- Then, above the list of files, click number branches, where the number indicates the current number of branches existing in the repository.
- Scroll to the branch that is to be deleted, then click the Delete symbol.
advertisement
Conversation
Your input fuels progress! Share your tips or experiences on prioritizing mental wellness at work. Let's inspire change together!
Join the discussion and share your insights now!
Comments 0