Git rebase How can I use it to collapse the ranks of ancient goals

Now I have a big buzz, bloated, Git repository consuming a lot of disk space on GitHub that I want to diet. I need to abandon the ancient commits made at the beginning of the history of the project, which essentially are not related to the current direction of the project.

I - and always will be - the only user of this private repo.

Ideally, I could do something like:

git rebase from-birth-of-repo-only-one-month-ago

Thanks
Doug

+5
source share
3 answers

, git rebase -i HEAD ~ Number, Number inital commit. , , , , . .

+2

--squash git merge git 1.4.1 . , . , 143eff , , master " " dcb7e5, :

# Save the old position of "master" by creating a branch old-master:
$ git checkout master
$ git branch old-master

# Create and checkout a branch called "new-master" that at the old commit:
$ git checkout -b new-master 143eff

# Stage the effects of merging the "one month ago" commit:
$ git merge --squash dcb7e5
Updating 143eff3..dcb7e5b
Fast-forward
Squash commit -- not updating HEAD
[... status output showing the staged changes ..]

# Create the squashed commit:
$ git commit -m "A commit squashing history up to a month ago"
# (You could use --amend if you want them to be squashed into 143eff
# instead of being a commit after that.)

git diff dcb7e5 new-master, .

:

$ git rebase --onto new-master dcb7e5 master

rebased master, . ( , git diff old-master master git log. github --force, :

# Push master to github, with "--force", since you've rewritten history:
$ git push --force origin master

new-master, squash commit, :

git branch -d new-master

, github git gc --auto , ...

+7

, Git 1.7.2 :

start=$starting_sha1
git checkout --orphan new_master $start
git commit -m 'new root'
git rebase --onto new_master $start master
git checkout master
git reset --hard new_master
git push -f origin master

Cleaning up old objects that you no longer reference refers to works more because reflexes, caches, tags, other branches, etc. can point to them. Once you are sure that they have been fixed or removed, one or more of the following should help:

git prune
git gc
git repack -ad
+1
source

All Articles