0

I created a new repository which has exactly the production content. I want to have this content in my local devel environment. So I need to get that content from the repository. What I did was, in my local master branch:

  1. get the content (in branch origin/master)

    git fetch

  2. merge and overwrite my local master branch (as it's explained in this question Git: Merging but overwriting changes).

    git merge -X theirs origin/master

  3. commit changes

    git commit -am 'merged overwriting form origin/master'

but then when I do

git diff origin/master

I should see no differences, but I still see them. Someone knows why?

There are other ways to force git overwrite files on pull I can try, but I'd like to understand what I'm doing wrong.

Community
  • 1
  • 1
de3
  • 1,890
  • 5
  • 24
  • 39

2 Answers2

0

when you do:

git diff origin/master

you are comparing against the remote repository

you said you did some commits (step 3) but you didnt push them to the remote. therefore you will see changes.

if you want to change the local to be the same as the remote. then do:

git reset origin/master

which will reset you local repository to be the same as the remote.

note that ti will remove comiitted changes.

Udy
  • 2,492
  • 4
  • 23
  • 33
0

"git merge -X theirs" will try to merge the changes without conflict. IF there is a conflict, it will resolve it by taking theirs over yours. So in cases where it has been able to merge in the changes from upstream without conflict, you will see a version that it a combination of yours and theirs.

In order to make your master branch an exact copy of origin/master, try this:

git checkout master
git fetch origin
git pull origin master
git reset --hard origin/master

The reset will discard any changes on your master branch that are not in origin/master.

naomi
  • 1,934
  • 1
  • 14
  • 29