Push your local directories to GitHub

ยท

2 min read

Assuming you are ready with your project directory and wanted to push into your github repository.


  1. Initialize directory with git
    git init -b main
    
  2. Add to staging and perform commit
    git add . && git commit -m "intitial Commit"
    
  3. But you are unable to push the changes. You need to create the repo before pushing. You can perform this using cli.github.com
  4. Install gh into your machine
    sudo apt-get install gh
    
  5. Then create repo using command
    gh repo create
    
  6. Oops! is it asking for authentication. haha :) stay conscious. Now run the command and specify required feilds
    gh auth login
    
  7. Rerun step 5. Specify Repo name, Desc, Visibility, and if you want to a remote name it something like origin. It initializes push commits to origin.
  8. Thats it. You are done. But is that really help in all cases? If yes end your reading here and if not you might faced the same thing what I've faced. exceeds GitHub's file size limit of 100.00 MB

Usage of git-lfs

Ofiicial docs: git-lfs.github.com

Installation

sudo apt install git-lfs

Track files

git lfs track "*.pkl" "*.csv"

Add .gitattributes

git add .gitattributes

Add files to stage and commit

git add . && git commit -m "large_files"

Push the changes to branch

git push origin -u main

failed !

 ! [remote rejected] main -> main (pre-receive hook declined)
error: failed to push some refs to 'https://github.com/Username/project.git'

Googling got me through this: stackoverflow.com/questions/33330771/git-lf..

Try migrating large files

git lfs migrate import --include="*.pkl"
git lfs migrate import --include="*.csv"

and push to git.

git push origin -u main

I'm done with my requirement and hope the same with you. ๐Ÿง๐Ÿค”

If not google is your saviour. Thanks for reading till the end. Bye ๐Ÿ˜‰

ย