Мэтт,
Вы уже продвинули репо, и кто-нибудь его потреблял?Если нет ... что более важно, если ваша история все еще ваша, вам нужно rebase , чтобы переписать вашу историю.Допустим, у меня есть репозиторий, например, со следующей простой историей:
$ git log --summary --stat
001d888 Yet some more work (Fred - 71 seconds ago)
file2.txt | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
3f74e79 Doing some more work (Fred - 2 minutes ago)
file1.txt | 1 +
file3.txt | 1 +
2 files changed, 2 insertions(+), 0 deletions(-)
8acc3d8 Adding some more files (Fred - 3 minutes ago)
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1.txt
create mode 100644 file2.txt
create mode 100644 file3.txt
fb3a2e1 Just added a big ole file (Fred - 4 minutes ago)
BigOleFile.blob | Bin 0 -> 33214460 bytes
1 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 BigOleFile.blob
6d0ab2b first commit (Fred - 8 minutes ago)
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
Представьте себе, что BigOleFile.blob - это ваш большой файл ...
Чтобы переписать историю, получите шакоммит прямо перед тем, который вы хотите удалить.В данном случае это:
6d0ab2b
И если ваш git-журнал сумасшедший, сделайте что-то вроде следующего, чтобы отфильтровать его и все же дать вам контекст вокруг матча:
git log --summary --stat | grep avi --context=10
Теперь перебазируйте вашу историю с помощью интерактивной опции.
$ git rebase --interactive 6d0ab2b
Вы получите что-то вроде этого:
pick fb3a2e1 Just added a big ole file
pick 8acc3d8 Adding some more files
pick 3f74e79 Doing some more work
pick 001d888 Yet some more work
# Rebase 6d0ab2b..001d888 onto 6d0ab2b
#
# Commands:
# p, pick = use commit
# r, reword = use commit, but edit the commit message
# e, edit = use commit, but stop for amending
# s, squash = use commit, but meld into previous commit
# f, fixup = like "squash", but discard this commit's log message
# x <cmd>, exec <cmd> = Run a shell command <cmd>, and stop if it fails
#
# If you remove a line here THAT COMMIT WILL BE LOST.
# However, if you remove everything, the rebase will be aborted.
#
Удалите строку с символом ша, в который был добавлен файл ... В данном случае это первая строка.Скорее всего, вам придется потом пройти через несколько запросов во время перебазирования, но это может быть довольно чисто, и вам это сойдет с рук.После того, как вы закончите, вы получите сообщение:
Successfully rebased and updated refs/heads/master.
Еще раз просмотрите журнал git, чтобы убедиться:
$ git log --summary --shortstat
7c499bb Yet some more work (Fred - 12 minutes ago)
1 files changed, 1 insertions(+), 0 deletions(-)
4dfa303 Doing some more work (Fred - 13 minutes ago)
2 files changed, 2 insertions(+), 0 deletions(-)
2f27c1b Adding some more files (Fred - 14 minutes ago)
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 file1.txt
create mode 100644 file2.txt
create mode 100644 file3.txt
6d0ab2b first commit (Fred - 19 minutes ago)
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 README
После этого нажмите на master:
$ git push origin master
Counting objects: 9, done.
Delta compression using up to 2 threads.
Compressing objects: 100% (6/6), done.
Writing objects: 100% (8/8), 751 bytes, done.
Total 8 (delta 2), reused 0 (delta 0)
To git@github.com:xxxxxxxxxxx/temp.git
6d0ab2b..7c499bb master -> master
Как вы можете видеть ... файл все прошло до свидания.