Can I add a file to my local Git repo but not push it to remote

Toby

I have a number of large video files which I don't want to push to my remote, I do however want to add them to my local repository. Kind of like a remote version of the .gitignore file.

Is that possible?

To be more specific, I'm working on a multimedia project and one folder has project metadata files (it's a Screenflow project) as well as media. So it has a project.screenflow folder with both .dat files and Media\XXXX.aif, Media\XXXX.mov etc.

I want to share at least the project files (.dat) with my team and it doesn't make sense to open the project up in Screenflow if you don't have the media it uses. However, there's a filesize limit of 100MB on our Git repo preventing me pushing those.

Currently, I've excluded Media in the .gitignore and may have to share the media by some other means :(

Shahbaz

.gitignore doesn't prevent you from having a file in your repository (you can always force it). So this is not really like a .gitignore in the remote.

The immediate answer to your question is that it's not possible. Git keeps a history of your commits. Every commit is made (and hashed) by its contents. If you have a file in a commit, and you push that commit, you can't ask git to push only part of that commit, because then it wouldn't be the same commit anymore.

However, there are ways to achieve what you want, none of which are very clean. One example is with git submodules where you create a submodule that points to another local repo you have (with the video files). Anyone cloning your remote repo would not receive the video files, but they still see the submodule that refers to somewhere in your computer.

Another way would be to use git subtree to actually create another set of commits from the ones you have, excluding the videos, and then push those artificially made commits to your repository. It however imposes some directory structure.

The usual answer to such a question often is to rethink your repository. Are the videos vital to your repository? If not, then don't put them in the repository, neither local nor remote. Extra resources like that don't belong in a git repository (especially since they are also not versioned).

If you only want them in your local computer, by all means just keep them in some other directory. If you really want to have access to old versions, keep that other directory under git on its own. If you want others to see the files too, put them on a file sharing website.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Why does Git show my local "pull from remote" when I push my commit to the remote repo?

From Dev

unable to push my local git repo to the remote repo

From Dev

How do I tell git to ignore my local changes, but leave the file in my remote repo?

From Dev

Pycharm -- how can I push a local project to a remote organization repo?

From Dev

Can I push a local repo to two remote repos?

From Dev

How can I push a git repo to a remote server through ssh?

From Dev

How can I push a git repo to a remote server through ssh?

From Dev

I want to add remote branch of my local repo?

From Dev

Why I can't add this remote GitHub repository to my local GIT repository as remote?

From Dev

Why can't I simply push 1 file to my repo without having to do a git pull?

From Dev

fatal: Could not read from remote repository. When I push my local repo to remote server

From Dev

Push local new Git repo to existing remote repo as branch?

From Dev

How can I build my local git repo on external server?

From Dev

Can't push a git repo on a local server

From Dev

How can I convert all the remote branches in a local git repo into local tracking branches

From Java

Push local Git repo to new remote including all branches and tags

From Dev

Create new repo by 'git remote add origin' and 'push'

From Java

Why is `git push --force-with-lease` failing with "rejected ... stale info" even when my local repo is up to date with remote?

From Dev

Can I change my .gitignore at a remote site and will it push to GITHUB repro when I do a git push?

From Dev

Push git alias to remote repo

From Dev

Failure to push to remote repo in Git

From Dev

If on a local branch, how should I push that repo to remote from local repo that already exists?

From Dev

How to remove a file from git repo on local and remote

From Dev

How can I auto-deploy my git repo's submodules on push?

From Dev

Cannot push to heroku after adding a remote heroku repo to my existing local repo

From Dev

reassign an existing remote repo to my local repo

From Dev

How can I push a branch into a separate remote repo?

From Dev

why can I not add an upstream git repo?

From Dev

Git: Push local file to a different file name in a remote repository

Related Related

  1. 1

    Why does Git show my local "pull from remote" when I push my commit to the remote repo?

  2. 2

    unable to push my local git repo to the remote repo

  3. 3

    How do I tell git to ignore my local changes, but leave the file in my remote repo?

  4. 4

    Pycharm -- how can I push a local project to a remote organization repo?

  5. 5

    Can I push a local repo to two remote repos?

  6. 6

    How can I push a git repo to a remote server through ssh?

  7. 7

    How can I push a git repo to a remote server through ssh?

  8. 8

    I want to add remote branch of my local repo?

  9. 9

    Why I can't add this remote GitHub repository to my local GIT repository as remote?

  10. 10

    Why can't I simply push 1 file to my repo without having to do a git pull?

  11. 11

    fatal: Could not read from remote repository. When I push my local repo to remote server

  12. 12

    Push local new Git repo to existing remote repo as branch?

  13. 13

    How can I build my local git repo on external server?

  14. 14

    Can't push a git repo on a local server

  15. 15

    How can I convert all the remote branches in a local git repo into local tracking branches

  16. 16

    Push local Git repo to new remote including all branches and tags

  17. 17

    Create new repo by 'git remote add origin' and 'push'

  18. 18

    Why is `git push --force-with-lease` failing with "rejected ... stale info" even when my local repo is up to date with remote?

  19. 19

    Can I change my .gitignore at a remote site and will it push to GITHUB repro when I do a git push?

  20. 20

    Push git alias to remote repo

  21. 21

    Failure to push to remote repo in Git

  22. 22

    If on a local branch, how should I push that repo to remote from local repo that already exists?

  23. 23

    How to remove a file from git repo on local and remote

  24. 24

    How can I auto-deploy my git repo's submodules on push?

  25. 25

    Cannot push to heroku after adding a remote heroku repo to my existing local repo

  26. 26

    reassign an existing remote repo to my local repo

  27. 27

    How can I push a branch into a separate remote repo?

  28. 28

    why can I not add an upstream git repo?

  29. 29

    Git: Push local file to a different file name in a remote repository

HotTag

Archive