How to interpret "deleted by us" after git rebase interactive

While working on aa special branch (from the "development" branch), I took the wrong approach (several times: /) and in fact I want to delete all my commits in this branch before my current commit.

What I did earlier in this type of situation is to do git rebase -i development and delete all the commits to the one I want to save (the most recent) and then do git push -force to update the remote repo to only contain my latest gold fix.

After that, when I manage to commit the changes to this overwrite commit, it looks like git is responding a bit strange to my request. There are several files that he says.

 both modified: app/helpers/statistics_helper.rb deleted by us: app/models/referrals/chart.rb deleted by us: app/views/statistics/_referrals.html.haml deleted by us: app/views/statistics/_referrals2.html.haml deleted by us: app/views/statistics/_referrals3.html.haml 

I do not know how to answer this. if I git add files that are preceded by "deleted by us", will these files be deleted?

+6
source share
1 answer

Deleting commits occurs as if they never existed. Therefore, if you added any files to previous commits that were simply deleted, these files will also be deleted. This is probably while you see this message. This will probably remove the changes to the pre-existing files that you wanted as part of your final result. I think you are using rebase incorrectly.

If at the end of your last commit everything is in the state you want, you should just squash your last commits instead. You can do this in several ways. Using rebase -i , as you did, and specifying s or squash instead of edit for all commit lines except the first, do this.

Another way to do this:

 git reset --soft HEAD~<N> git commit 

Where <N> is the number of revolutions needed for squash.

+1
source

All Articles