0

I did a large git commit about 5 commits ago on my local repo. I need to remove this commit, (really just the large files/videos that were with the commit) so that I can then upload my latest commits to github.

do I use the Rebase command in some way?

I basically need to remove the video files that I had added to this commit accidentally, but keep the code changes that were with this commit.

found this, but wanted to confirm before I try my first rebase: How can I remove a commit on GitHub?

Community
  • 1
  • 1
Mark W
  • 3,879
  • 2
  • 37
  • 53
  • 1
    Create a copy of your repo first just in case. You can follow those steps to do an interactive rebase and delete the commit, but the code changes will be removed too (if they're in the same commit) and you'll need to reapply them. Rebasing also gives you the option to edit a commit, which will let you unstage the video files and re-commit the code changes. Instead of deleting the line, follow the instructions for marking the commit for editing, unstage the video files, and then commit the code changes. – cjc343 Jun 18 '13 at 17:24

1 Answers1

1

You can use a tag to keep track of your commit history. This is one way to do a rebase like operation without using rebase.

It might go something like (several of the steps just to make sure things are okay):

git tag wip
git reset --hard wip~4
git rm -f file1 file2 ...
git commit --amend -C wip~4
git cherry-pick `git rev-list wip~4..wip`
git diff wip
git tag -d wip
git push -n

Another way is with rebase in interactive mode:

git rebase -i HEAD~5
cforbish
  • 8,567
  • 3
  • 28
  • 32