2

I have followed this answer (How to remove/delete a large file from commit history in Git repository?) to get rid of some big, unwanted files in a repository. I have done all the steps stated there in my local copy (because trying to do it in the bare, original, repository results in an error as long as it does not have a working tree). Nevertheless, when I finish the steps (having removed the files, etc.) and I do a "git status" on my local copy, I get

# On branch master
# Your branch and 'origin/master' have diverged,
# and have 16 and 18 different commit(s) each, respectively.

and I do not know how to send the changes back to the central repository. Can anybody help me?

Community
  • 1
  • 1
chronos
  • 325
  • 6
  • 12
  • To repeat the first bit from the first answer: **What you want to do is highly disruptive if you have published history to other developers.** This is because you cannot *change* any commit, you can only make new, slightly different commits that no longer contain the large files. Your branch now has 16 new commits. Everyone else will have to delete those same 18 old commits and switch to using the 16 new ones (as VonC notes in answer below). – torek Apr 23 '14 at 06:39

1 Answers1

5

Since you have change the history of your commits, you would have to force push them back to origin:

git push --force

This is dangerous and disruptive. Make sure to communicate that event (before pushing) to anyone having already pulled from your repo: they will need to reset their master branch to the one you just pushed:

git checkout master
git fetch
git reset --hard origin/master
Frxstrem
  • 38,761
  • 9
  • 79
  • 119
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250