1

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!

2 Answers2

1

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

tjheslin1
  • 1,378
  • 6
  • 19
  • 36
rnewed_user
  • 1,386
  • 7
  • 13
  • 1
    @tjheslin what would happen if this is in your own fork repository? also we need to report to our team? – rnewed_user Oct 23 '21 at 13:04
  • @rns3 a fork is a separate repo so that wouldn't affect the upstream repo the fork was based off of. I'd only recommend making all of those changes before an affected branch was merged into the fork - likely via a Pull Request. – tjheslin1 Oct 23 '21 at 16:07
  • 1
    For me this didn't work. This is what worked for me, again this was after I mad the push to the repository: git rm -r .classpath that's it. worked every time regardless if it was a file or folder. taken from youtube : [link] (https://www.youtube.com/watch?v=ca_-OXBQtGw) – Babycoder99 Oct 26 '21 at 20:33
  • @Babycoder99 can you post your answer please – rnewed_user Oct 26 '21 at 20:41
0

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