일부 기록을 잃지 않기 위해서; 먼저 저장소의 복사본을 가져와야합니다 :). 여기에 우리가 간다 : (<f>
당신이 커밋 새로운 루트하려는 커밋 (F)의 샤하다)
git checkout --orphan temp <f> # checkout to the status of the git repo at commit f; creating a branch named "temp"
git commit -m "new root commit" # create a new commit that is to be the new root commit
git rebase --onto temp <f> master # now rebase the part of history from <f> to master onthe temp branch
git branch -D temp # we don't need the temp branch anymore
당신은 당신이 같은 잘린 역사를 갖고 싶어 원격이있는 경우; git push -f
을 사용할 수 있습니다. 경고 이것은 위험한 명령입니다. 이것을 가볍게 사용하지 마십시오! 마지막 버전의 코드가 여전히 동일하게 유지되고 싶다면, git diff origin/master
을 실행할 수 있습니다. 변경 사항은 표시되지 않아야합니다 (기록 만 변경 되었기 때문에 파일 내용은 변경되지 않음).
git push -f
다음 두 명령은 옵션입니다. git repo를 양호한 상태로 유지합니다.
git prune --progress # delete all the objects w/o references
git gc --aggressive # aggressively collect garbage; may take a lot of time on large repos
['rebase'] (https://git-scm.com/docs/git-rebase)는 히스토리를 변경하는 도구입니다. – Maroun
해결하려는 문제는 무엇입니까? –