S
S
Svyatoslav Khusamov2017-02-04 20:02:07
git
Svyatoslav Khusamov, 2017-02-04 20:02:07

How to undo "git add" after a commit?

How to undo "git add" after a commit?
I did the following:
git add .
git commit -m "Cool commit"
And after that I discovered that I accidentally added a 1.5 GB long file!
What needs to be done to get it out of there now?
Naturally, all the edits that I have committed, I would like to save.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
aol-nnov, 2017-02-04
@aol-nnov

add has the opposite of rm
doing it and another commit

L
lega, 2017-02-04
@lega

I would probably do
1) cherry-pick --no-commit to a temporary branch
2) "delete" an unnecessary file, commit
3) roll back the master to 1, reset --hard HEAD~1
4) merge temp_branch is
ready
You can also try deleting file on the next commit, and then collapse these 2 commits via rebase

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question