Working with branches in Amazon CodeCommit repositories - Amazon CodeCommit
Services or capabilities described in Amazon Web Services documentation might vary by Region. To see the differences applicable to the China Regions, see Getting Started with Amazon Web Services in China.

Working with branches in Amazon CodeCommit repositories

What is a branch? In Git, branches are pointers or references to a commit. In development, they're a convenient way to organize your work. You can use branches to separate work on a new or different version of files without affecting work in other branches. You can use branches to develop new features, store a specific version of your project from a particular commit, and more. When you create your first commit, a default branch is created for you. This default branch is the one used as the base or default branch in local repositories (repos) when users clone the repository. The name of that default branch varies depending on how you create your first commit. If you add the first file to your repository by using the CodeCommit console, the Amazon CLI, or one of the SDKs, the name of that default branch is main. This is the default branch name used in the examples in this guide. If you push your first commit using a Git client, the name of the default branch is what the Git client specifies as its default. Consider configuring your Git client to use main as the name for the initial branch.

In CodeCommit, you can change the default branch for your repository. You can also create and delete branches and view details about a branch. You can quickly compare differences between a branch and the default branch (or any two branches). To view the history of branches and merges in your repository, you can use the Commit visualizer, which is shown in the following graphic.


            A view of branches in a repository

For information about working with other aspects of your repository in CodeCommit, see Working with repositories, Working with files, Working with pull requests, Working with commits, and Working with user preferences.