New branch from current branch

 How do I create a new branch in Git? | Learn Version Control with Git (git-tower.com)


How do I create a new branch based on the current HEAD?

To create a new branch that is based on your currently checked out (HEAD) branch, simply use "git branch" with the name of the new branch as the only parameter:

$ git branch <new-branch>

How do I create a new branch based on some existing one?

If you want to base your new branch on a different existing branch, simply add that branch's name as a starting point:

$ git branch <new-branch> <base-branch>


How do I create a new branch from a specific commit?

If you want to start your new branch based on a specific commit (not a branch), then you can provide the commit hash as the starting point:

$ git branch <new-branch> f71ac24d

How do I create a new branch from a specific tag?

You can also base your new branch on a specific tag you already have in your repository:

$ git branch <new-branch> v1.2

How do I create a new branch from a remote branch?

To take a remote branch as the basis for your new local branch, you can use the "--track" option:

$ git branch --track <new-branch> origin/<base-branch>

Alternatively, you can also use the "checkout" command to do this. If you want to name the local branch like the remote one, you only have to specify the remote branch's name:

$ git checkout --track origin/<base-branch>

How do I create a new branch in a remote repository?

After working on your new local branch for some time, you might want to publish it in your remote repository, to share it with your team:

$ git push -u origin <local-branch>

The "-u" flag tells Git to establish a "tracking connection", which will make pushing and pulling much easier in the future.

Không có nhận xét nào:

StaticImage

  import React , { useEffect , useRef } from "react" import { StaticImage } from "gatsby-plugin-image" impor...