0

Git beginner here...

I use it with Visual Studio exclusively. I've made 18 commits since the last push to the remote server and commit number 5 has a large file in it that I did not intent to be in there. Because it is over 100MB, I cannot push to the remote server.

How do I edit that old commit and remove that file?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Michael
  • 87
  • 1
  • 10

2 Answers2

1

If you can use the command-line git tool, it's easy. Assuming your remote tracking branch is origin/master:

git rebase -i origin/master

This will bring up an editor containing a list of your unpushed commits. Find the commit you want to edit, change the word pick to edit, save and exit.

You should see a message stating that you're now editing the commit in question. Now just:

git rm big_bad_file
git commit --amend
git rebase --continue

And you're done.

Nathan Dorfman
  • 331
  • 1
  • 3
0

Well, you can delete commit number 5 from commit history. git log -to see the various commit, with their hash values

and use git reset hash value- to uncommit that from history and also remove form staging area and then you can delete that file and commit again

Jatin Mehrotra
  • 9,286
  • 4
  • 28
  • 67