Search code examples
gitversion-controlgit-branchgit-push

What is the most efficient way to push a set of changed commits in to a remote git repository?


I have a remote git repository with nearly 1000 heavy commits, that is:

C1 -> C2 -> C3 -> ... -> C949 -> C950 -> ... -> C1000

Recently, I found that in commit C950, I have added large binary objects into the repo. I removed the files in my local repository using the git filter-branch --index-filter command. Now my local repository looks like this:

C1 -> C2 -> C3 -> ... -> C949 -> C1001 -> ... -> C1051

I know that I can undo my commits on the remote repository and then push the changes. But regarding my large commits, I want to make sure about the most efficient way to pushing my changes to the remote repository.

Update 1: Up to now, it is clear that I should go for a push-force on my remote repository. But the point is that my remote repo does not allow nonFastForward merging. Is there any other way to fix this issue?


Solution

  • At the moment you are attempting to rewrite some changed commits (C1001 -> .. -> C1051) into your repo that you have already pushed them before (i.e. commits C950 -> .. -> C1000), so, you have to force the push.

    And regarding your FastForward configuration on the remote repo, you should have direct access to your remote repo to change the configuration.