How can I push git-replace to a remote repo?

I used "git replace" to replace branch (no common ancestor) 22b2b25 to commit to master. I want this change to be permanent. I am not interested in the previous history. In the output below, the first five commits are from the original master branch, while the bottom 2 comes from a different branch.

When I moved it to the new repository, git-replace was lost and the old history reappeared. Is there a way to make this change permanent?

The branch branch looks like below in the original repo. I want to see this in the remote repo and subsequent clones.

[mike@localhost canal_site]$ git log --oneline --decorate
cdf0ae3 (HEAD, origin/master, master) MM: sqlencode course name for ad-hoc courses
2b57df5 MM: fixes for changes so far
7916eaf MM: ad hoc - more refactoring
1e00d22 MM: reformatted code
e36cee1 factored out equal ops
22b2b25 (origin/prod20140313, prod20140313) initial load from production 9-June-2015
08379cd initial inclusion of production files from 9-June-2015

      

+3


source to share


1 answer


git replace

not enough: replacing one commit is not enough.

The next commit should now refer to the replaced commit as its parent.

As mentioned in " Removing a whole bunch of commits from git ":

Backing up your repo with git clone.
Figure out the first commit you make after commits you don't like and remember the hash of your direct ancestor (next bbb

).
Then find the first commit you make before the commit doesn't like it (in the following aaa

):



git replace bbb aaa

      

Take a look at your repository (with help git log

) and check if everything is as it should be after your intended change.
But the command replace

just adds some meta information to .git/refs/replace

which the git commands interpret accordingly.
To make these changes permanent, you can use git filter-branch

:

git filter-branch -- --all

      

Then you will need to force push (git push -force) to override the remote repo with the new branch history. Or you will just push to a new empty empty repo.

+3


source







All Articles