More About Git Branche’s

More About Git Branche’s

Types Of Files

  • UNTRACKED

    A new file is discovered by Git in the working directory.

    This particular file has never been included in the index. Git flags this file as "untracked," indicating that you should probably add it to the index and eventually commit it.

  • STAGED

    The index now includes a file. If you added this particular file to the index for the first time, Git starts keeping track of it. No matter what, adding a file to the index designates it as "staged."

  • UNMODIFIED

    Each file you added to the index is taken by Git and committed to memory as soon as you commit. All of those files are thus designated as "unmodified." You should all aspire to be in this situation. This indicates that the file's contents are securely stored in Git's memory

  • MODIFIED

    A file enters the modified state if you make changes to it after it has been committed as a reminder to commit it later.

Branche's

  • This makes it possible for development to advance in several directions at once.

  • Since Git supports several branches, numerous distinct lines of work can coexist in a repository at any same time.

  • The stages of your project's lifetime, such as stable, development, release candidate, and production release, can be reflected in a branch. This can bring about clarity and facilitate teamwork in a methodical and coordinated way.

  • An individual product release is also frequently represented as a branch. You have the choice to preserve the earlier release version as a separate branch for backward compatibility if you wish to start a new release version of your project but you anticipate that some of your clients may choose to continue with an older release version.

  • In an isolated development environment, a branch allows you to iterate and work on a particular feature or to look for a fix for an issue in your project. As a result, you may establish many feature branches that each include a set of well-defined concepts or ideas, which you can then combine via a merge before publishing a new version. When working with tiny modifications in each branch you make, this strategy is encouraged because Git's branching mechanism is comprehensive yet affordable and is not viewed as overkill. The word feature simply means that each branch in the repository serves a specific function.

  • The effort of a single developer might be represented as a single branch in a big, complicated project. Teams with complex project development requirements can use this technique of working to implement the many moving pieces of a project separately before combining and unifying the various moving parts into a final product for certain releases.

When To Use?

  • If you are working on a feature you should use a separate branch for it.

  • Do not edit the main code.

  • Use a different Branch for every new feature.

  • If you have to do some changes to a previous feature you can use the existing branch.

Guidelines

  • There are a few straightforward principles that branch names must follow

  • To establish a hierarchical naming scheme, use the forward slash (/). The name cannot, however, conclude with a slash.

  • Anywhere in the name, there cannot be two consecutive dots (..).

  • There cannot be any blank spaces or other whitespace characters in the name.

  • Git-specific characters like the tilde (), caret (), colon (:), question mark (? ), an asterisk (*), and open square bracket ([) are not permitted in the name.

  • The ASCII control character, which is any byte with a value lower than 1040 octal, as well as the DEL character (1177 octal), are not permitted in the name.

About MAIN Branch

  • Git also established a branch called main when we initialized our repository in the background.

  • Git needs to know what to name the first branch when we create our first branch locally and initialize a Git repository.

  • The very first branch that Git creates in our repository is given the default name of "main".

  • Our major area of expertise is the main branch. The term "main" itself has no special meaning; we might have given a different name to our initial branch by changing the value of the init.defaultBranch variable.

  • The default name for the first branch generated in a Git repository at the time of its creation was master. It was determined that this naming should change to main in 2021. The ethical implications of the master terminology were the fundamental cause of this. As of 2022, the master will continue to be the default name for our first branch if we begin working on a Git project, our first commit is made in our local repository, and we are using the default Git setup options.

  • Although you are free to choose another name, the community is now moving towards adopting main as the default, therefore we specified this in our Git settings.

General Knowledge

  • You cannot have Whitespaces in the Branch name.

  • Use hyphens or underscores if you want a branch name with more than one word. Git will alert you to the error "is not a valid name" if you try to include a space in the name of your branch. However, forward slashes () are acceptable!

  • If you try to create a branch with a name that already exists Git will error out and inform you that a branch with that name already exists, just like with an incorrect branch name. Before starting a new branch, it's a good idea to run the git branch to identify all the existing branches in your repository.

  • There is no limitation on creating branches.