0

I'm currently part of a very large open-source project. I'm assigned to work on few features and I'd like to create a branch for each new feature, and once it's done, merge it with the master branch.

For the sake of working from different machines since I move a lot, I decided to push the feature branches to my private repository, say the original repository is origin and my private repository is private.

Currently I cloned the project and created 2 branches from master, feature1-branch and feature2-branch. When I tried to push the branches to my private repository, I get an error because the project contains files that exceed +100mb. (Github max file size limitation)

I changed my .gitignore to ignore the big files, but it seems since they're committed in previous/history commits, they still get pushed and cause the error.

Is there a way to push only the files in my new commits without pushing all the history commits? I'm guessing that's not an option because that will cause a merge refusal if I try to make a pull request on a different machine (different histories can't be merged I believe)

I'm no expert in Git, so I'm looking for an advise on what's the best way to handle such scenarios?

P.S Currently I just make sure to copy the files I changed and put them in a cloud storage, and copy them back and forth to the project on different machine, but that's tedious and impractical work.

Thanks in advance, cheers.

NightwareSystems
  • 433
  • 5
  • 17
  • Could you please repeat in couple of words what exactly your problem is? – Mara Oct 23 '18 at 12:28
  • I got a super big project, that contains big files, I want to add 2 new features to this project, so I create 2 branches, 1 for each. I need to push those 2 branches to my private repository, so I can work on them while I'm traveling, but the large size of the project, and some files (exceeding the github size limit) prevents me from doing that (gives error for push command), so I'm asking what's my alternative? Is there a way to ONLY push the changed files and not the whole project in each branch? When I push a branch commit, it pushes the history of commits, which includes those big files. – NightwareSystems Oct 23 '18 at 12:51
  • I tried excluding the big files in the `.gitignore`, but since they exist in the previous history commits, they still get pushed and this causes the error. – NightwareSystems Oct 23 '18 at 12:52
  • So "private" is another remote? – evolutionxbox Oct 23 '18 at 13:18
  • Yes indeed, private is my private remote repository, please see the question above, I edited it to be clearer and to the point, thanks. – NightwareSystems Oct 23 '18 at 13:24
  • 1
    As soon as file was pushed you will have it in history. And even if you remove it and will create your repository this file which already was removed will be still downloaded. Solution could be is removing file from git master and somehow remove it from git server/database. Anyway if file is such big it is a sign to remove it. – Mara Oct 23 '18 at 13:30

1 Answers1

1

To untrack a specific file, git rm --cached filename. (this will make it look like you deleted the file in your private repo; see https://stackoverflow.com/a/40272289/6951428 for alternatives if this is unwanted)

As you've seen, there's a distinction between ignored and untracked files. To put it simply, ignoring will avoid tracking and staging a file unless you explicitly tell git otherwise (for example, via git add -f or, as in your case, by having already been tracking those files prior to adding them to gitignore).

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details. - https://git-scm.com/docs/gitignore

junvar
  • 11,151
  • 2
  • 30
  • 46
  • I did try the `rm --cached` but it seems that will remove it from my current commit only, since it exists in previous commits, it will still try to push it. Thanks for the comprehensive answer, I will look in the two other alternatives. – NightwareSystems Oct 23 '18 at 15:16