Remove a file from git which is not pushed yet but also not in latest commit?

前端 未结 1 453
悲哀的现实
悲哀的现实 2021-01-27 05:27

I\'ve found this wonderful help-page of git:

https://help.github.com/articles/working-with-large-files/

and both approaches are not working for me... i

1条回答
  •  爱一瞬间的悲伤
    2021-01-27 05:54

    You can do an interactive rebase and 'fix-up' the commit that removed the unwanted file into the commit in which you added it. This will essentially leave the original commit as though the file was never added.

    From the command line (you need to commit/stash any changes):

    git rebase -i origin/master
    

    You'll be presented with a text editor in which you can manipulate the commits you made, from top to bottom. Move the "removed..." commit up so that it comes directly after the _"MOJ-1120..." commit. Change the pick to fixup, save the file and exit.

    If this doesn't do what you want, you can use the git reflog to go back to where you were beforehand. You may like to write down the current SHA before doing this to make it easier.

    0 讨论(0)
提交回复
热议问题