Home > Software design >  Push a file to Github/Gitlab without adding it to .git?
Push a file to Github/Gitlab without adding it to .git?

Time:11-08

I have a bunch of large files which never change and they end up occupying a ton of space in .git.

Is it possible to git add and git commit files (such that you can git push them) without them being added to .git?

CodePudding user response:

(in this problem if you don't want to push it to Github you can just gitignore your files in .gitignore)

create your .gitignore file in your project

touch .gitignore

then add files you want to .gitignore by writing it, example:

example.mp4

or

*.mp4

But if you want to push it to github you can use git LFS (Large File Storage)

Download and install git lfs:

git lfs install

now you can select the file types you'd like Git LFS to manage:

git lfs track "*.psd"

if your file mp4 then you can do this:

git lfs track "*.mp4"

or for specific file:

git lfs track "example.mp4"

now make sure .gitattributes is tracked:

git add .gitattributes

last step. Just commit and push to Github as you normally would, good luck. for more details -> https://git-lfs.github.com/

hope this helps :)

CodePudding user response:

As Acla Putra said, the clever idea is to create a .gitignore file. I also suggest you this way.

On the other hand, git add is the tool used to select what you want to track for your next commit. If you want to track all your files you can use git add . or, on the othen hand, if you want to decide what you want to track you can use git add file1.c, git add file2.txt etc...

Look at Git add description

  • Related