Reputation: 1409
I have a private repo with a single commit on Github -- specifically for a Rails project. My schema file was changed along with migrations, and a fellow dev wants me to remove the schema changes from the commit (and the private repo). I thought I had it figured out but it doesn't seem to be sticking, what am I doing wrong?
git reset 'HEAD^1' db/schema.rb
git commit --amend -v
git push origin <branch-name> -f
Upvotes: 0
Views: 1175
Reputation:
It looks like you didn't stage the changes made to db/schema.rb
after doing the reset and before doing the commit. So after you do git reset 'HEAD^1' db/schema.rb
, stage the file with git add db/schema.rb
, then do the commit.
Alternatively, you can reset the file to the previous state and keep it staged in the index by using git reset --soft head^
instead of git reset head^
. The latter uses the --mixed
flag by default, which will not stage the changed state, while the former will.
You can read more about the git reset
flags in the documentation:
--soft
Does not touch the index file nor the working tree at all (but resets the head to , just like all modes do). This leaves all your changed files "Changes to be committed", as git status would put it.
--mixed
Resets the index but not the working tree (i.e., the changed files are preserved but not marked for commit) and reports what has not been updated. This is the default action.
Upvotes: 2