6

I have develop & master branches, my develop branch is messy now and I would like to reset it and make it as a copy of my master. I'm not sure if merging the master into develop will make both of them identical. after trying to merge I got many conflicts I solved them using:

git merge origin/master
git checkout 

Is this enough for develop branch to be an identical copy to master

nwinkler
  • 49,757
  • 20
  • 150
  • 164
RaviPatidar
  • 1,326
  • 16
  • 28
  • Why would you want to merge your `dev` branch back into `master` if it is "messy" and you want to "reset" it? – Thomas Stringer Jul 20 '15 at 14:47
  • 1
    possible duplicate of [Reset my local repository to be just like remote repository HEAD](http://stackoverflow.com/questions/1628088/reset-my-local-repository-to-be-just-like-remote-repository-head) – Andrew C Jul 20 '15 at 21:10

2 Answers2

5

Literally you have the answer to your question in the own question:

git checkout dev
git reset --hard master

git reset allows three possibilities:

  • soft: Move the branch to the point you decide, but it does not touch your index area and working directory.
  • mixed: (by default) the same as soft plus changes the Stage Area. Do not change your working directory.
  • hard: The same as mixed plus changes the working directory.

To understand better: git reset

blashser
  • 788
  • 5
  • 12
4

A merge will not be sufficient, since you will have the changes from both branches (develop + master) in the develop branch after the merge.

If you want to get rid of the current develop branch and create a new one, do the following:

# Check out the master branch
git checkout master

# Delete the current develop branch
git branch -D develop

# Create a new develop branch
git checkout -b develop

Only do this if you are really sure that you don't care about the current develop branch!

If you have a remote copy of the develop branch, you will have to take caution when pushing the new branch:

  • Either delete the remote branch first (before pushing the new one): git push origin :develop, or
  • Push with the --force switch

Both will change the history for other people that have previously pulled the current develop branch.

nwinkler
  • 49,757
  • 20
  • 150
  • 164