Good Day People!,
On my repository i am using a .gitignore file but forgot to add the bin folder to the .gitignore file, before pushing to my repository.
I read here: Ignore .classpath and .project from Git
I used: git rm --cached bin, And that doesn't work. This is the error message I get: fatal: pathspec 'bin' did not match any files.
Is there another way to role back changes once they've been pushed to the repository?.
Thank you and have a good day!
CodePudding user response:
To reset the push apply this: git reset --soft HEAD^1
Will appear files modified so reset them or save: git reset <files>
or git stash
new commit to rollback: git commit --amend
and push: git push -f
Caution: Before running the above command it is recommended to make the other users of the repo, if any, aware that intend to do a -f
(--force
) as this rewrites part of the history of the git repo. Users who have pulled the change you are going to overwrite will need to handle this rewrite and may have based their work on the commit that is being overwritten. See this link in the Git docs for more info.
now you can do again your task
CodePudding user response:
after trying the above and other suggestions this is what worked. This was AFTER I pushed to the repository I was able to to remove the files and folders I designated using the following command:
git rm -r <folder/file name>
I found the fix by following this short tutorial