Rollerball
Rollerball

Reputation: 13118

Git: getting a branch equal as the master branch

I have created a new branch with some changes in it, I would like to still have the new branch but identical to the master branch. Is it possible to "override" a branch with another one's content?

Thanks in advance.

Upvotes: 2

Views: 2239

Answers (2)

René Höhle
René Höhle

Reputation: 27325

This is one of the main functions of GIT. Merge the content of the master branch in your feature branch and you have have all changes from the master in it but with your changes you made in your feature branch.

git merge master

if you don't need the changes of your feature branch then reset the branch to the master branch.

git reset --hard master

Or what is much easier make a new branch from the master.

Upvotes: 1

Matt Indeedhat Holmes
Matt Indeedhat Holmes

Reputation: 725

it is indeed in the git console go to the branche you want to override and type git reset --hard <branch name> it will override the branch you are on with the content of <branch name>

Upvotes: 5

Related Questions