Branching means diverging from the mainline and continue to work separately without messing with the mainline. Nearly every VCS has some form of branch support. In Git, a branch is simply a reference to the commit, where the following commits will be attached.
Git vs SVN: In recent years, the use of git has risen tremendously. Unlike SVN, git allows users to work on their own copy of the repository. One of the main reason for git’s success is its speed. Since all the files are stored locally on the developer’s computer, he/she has access to all even in very poor internet connection. Branching in other VCS can be an expensive operation in both time and disk space.
Git vs Other VCS: Git branching feature is what that sets it apart from other VCS tools. Git branch operation is nearly instantaneous, making the flow of switching back to branches and forth very smooth. Following are the few pros why git is preferred over other VCS:
- High operation Speed
- Full history of tree available
- Branch Operations
- Sorted Distributed Model
Branches: When you make a commit, Git stores a commit object that contains a pointer to the snapshot of the content you staged. This object also contains the author’s name and email address, the message that you typed, zero parents for the initial commit, one parent for a normal commit, and multiple parents for a commit that results from a merger of two or more branches. A branch as discussed earlier is a separate line of development as git stores branch as a reference to commits.
Note: Git branch is used to list, create or delete branches and it’s easier to logically divide up your work than have big beefy branches.
Git Branch- options
|git -a||This options list both remote-tracking branches and local branches.|
|git branch – – list||Activate the list mode or simply git branch list all the branches of repository.|
|git -c “Branch”||This option is used to Copy a branch.|
|git -C “Branch”||It is a shortcut for – – copy – – force|
|git -d or – – delete “Branch”||This option deletes specified branch. The branch must be fully merged in its upstream branch.|
|git -D “Branch”||This is a shortcut for – – delete – – force. It deletes the branch even if it has unmerged changes.|
|git -m “Branch”||This option move/rename the branch.|
|git -M “Branch”||It is a shortcut for – – move – – force.|
|git -q or – – quiet||when creating or deleting a branch, this option suppresses non-error messages.|
|git -r or – – remote||This option is used to list all the remote-tracking branches. If used with -d, this can also be used to delete remote branches.|
|git -t or – – track||When you create a new Branch it set up configuration to mark the start-point branch.|
|git – -no-track||It does not set ip the “upstream” configuration.|
|git – -edit-description||It edits the description of what the branch is for.|
|git – – – -contains [
||Show the list of branches that contain specified commit.|
- Git branch listing the one and only branch of the project ie. Master Branch
- Renaming Master Branch
- Copying “Branch2” and creating “branch3”
- Deleting “branch3”
- CSS Introduction
- WML | Introduction
- Introduction to LeSS
- Introduction to ES6
- SAP | An Introduction
- HQL | Introduction
- p5.js | Introduction
- Next.js | Introduction
- Ajax | Introduction
- Introduction to Express
- Introduction to KnockoutJS
- VBScript | Introduction
- Introduction of Vault
- Introduction to Anime.js
- Introduction to OpenStack
- Introduction of BioChip
- Prolog | An Introduction
- Introduction of Server
- Introduction to Semantic UI
- Underscore.js | Introduction
Following are the series of snapshots of executions of above few commands.
Summarizing: In this article, we discussed the high operation speed and branch behavior. We learned about the git branch command whose primary function is to list, create, delete branches. We also learned about various git branch option to fully implement the functionality of this command.
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.