1
crisz
4y

I had mistakenly added a large file to a commit, and I'm now spending 3 hours of my life just to remove it and being able to push.

I've deleted the file from tracking, but it remained in history so when I try to push, github rejects to continue.

And, still worse, trying various solutions on StackOverflow I've done a mess on the history which now looks unrelated to the remote one, and I think it's a never-end catastrophe.

It's absurd how badly designed is git, and how hard it is to use besides the 3 commands that you learnt by heart

Comments
  • 2
    Been there, done that. First months at my first job, I somehow decided it's a good idea to commit a 1 GB .PSD.

    Can't remember how and whether I fixed it at all (I must've), but what I'd try now is resetting the local branch to the commit just before adding the file, then force pushing. I'm not a git expert, but that sounds about right to me. I might be wrong of course.
  • 0
    @kamen that's a good idea, but I should go 7 commits back, and I don't even know if it's now possible
  • 0
    now I deleted the files through "git filter-branch", I'm trying "git push --force", and it's pushing 3000 objects. What the hell is it pushing?
  • 2
    * backup file
    * delete file
    * comit "deleted"
    * restore file
    * add to gitignore
    comit

    optional : SquashCommits so noone can see that ;p
  • 3
    The point of version control is to show the history. It shouldn't be easy to rewrite history.

    @NoToJavaScript it's still in the repo after that, and everyone has to download it if cloning the full history of that branch
  • 0
    @electrineer True. But how often full history is downloaded ?
  • 2
    @fzammetti having worked with three different version controls before git I can say git is the best so far.

    Sure there might come something better but git has survived and replaced most of the older ones.

    You just have to really follow the rules OR learn how it really does work to be able to fix problems.

    But many of the older ones was worse in that once you had done something stupid you could not easily back track.

    You might have to manually setup versions to preserve and any changes in between would be lost :/
  • 1
    Git, compared to svn, is good. If you're having so many problems, use a gui. Gitkraken is pretty good. It even let's you undo changes to the repo.
  • 2
    @NoToJavaScript Git always downloads the full history, there's no difference between client and server. For text repos that's fine. I've seen several gb build tools in a repo, made it a bit slower but from a local server, no biggie
  • 1
    @NoToJavaScript There's the "--depth" flag that can be added (with a numeric argument denoting the number of commits including the last one) when cloning, but unless you provide that flag, full history of the repo is cloned.

    https://stackoverflow.com/questions...
  • 0
    @NoToJavaScript I didn't mean to delete the file, just wanted to untrack it
  • 0
    @neeno yes but I wanted to remove a file from a commit, not a commit. I've solved now, I'll try it the next time just in case, thank you.

    By the way, also the worst designed software can be used if you learn how to use it. That's what make it bad designed, you've to learn it by heart.

    For example, what's the purpose of ~ in your solution? I should do some research for that, and it could have been avoided
  • 1
    @neeno very true.

    Also, git was designed specifically for managing the linux kernel and follows the same philosophy as most linux tools.

    Its a command line tool that does one task, version control, and it is powerful.

    It was never designed with friendly for beginners in mind but for managing the most complex software projects that exists.

    I mean, Microsoft have replaced their own tool with git for windows, that is a good sign its a good tool.

    And to be honest, once you need some of the more complex features, git IS easy to use compared to all previous tools. And i switched from using a gui version just because I found that it hid to much of the features.
Add Comment