Skip to content

Instantly share code, notes, and snippets.

@Vishal023
Created July 21, 2020 05:04
Show Gist options
  • Save Vishal023/889aadce773bc40abe32be2e57da9d8a to your computer and use it in GitHub Desktop.
Save Vishal023/889aadce773bc40abe32be2e57da9d8a to your computer and use it in GitHub Desktop.
How to use git branch

Git Branch

Git’s branching functionality lets you create new branches of a project.

View Branch

git branch

Create a branch

1.  To just create a branch 
    git branch branch-name

2.  To create a branch and move to it
      Method 1 : 
        git branch branch-name
        git checkout branch-name
      Method 2:
        git checkout -b branch -name

Rename a branch

git branch -m old-branch-name new-branch-name

Compare a branch

git diff first-branch second-branch

Merge a branch

git checkout branch-in-which-you-have-to-merge
git merge branch-which-you-want-to merge
@Vishal023
Copy link
Author

Cheatsheet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment