How to upload a project on GitHub using Git

The process is rather simple, I have jotted down all the steps in the bullets below:

  • Click on “New”.
Create a GitHub repository
  • Enter the name for your repository. Select whether you wish to keep it private (only you can see it), or make it public (visible to everyone). Then click on “Create Repository”.
Configure your repository’s settings
  • A new page will open. From that, copy the below line (it will be different for each repo), you’ll need it later:
URL for remote repository hosted on GitHub
  • In your terminal/command prompt, navigate to your project directory:
Navigate to your project directory
  • Run git init ; it will initialize a local repository in that folder.
git init
  • Run git add . ; it will add all the files in that folder to the local repository.
git add .
  • Run git commit -m "<Enter a short text to describe your commit>"
git commit -m “<commit message>”
  • All the files in your project are now committed to your local repository.
  • Now, you need to sync your local repository (that is on your PC/system) with the remote repository (that is hosted on GitHub). To do that, first paste the command you copied earlier which specifies the URL of the remote repository, it will link your local repo with the remote repo:
git remote add <remote repo’s URL>
  • Run git push -u origin main; this will push/sync the changes/code from the local repository to the remote repository on GitHub.
git push -u origin main
Large files – use Git LFS
  • Go to GitHub and refresh the page that you were on. You should now be able to see all the files in your GitHub repository.
  • That’s it!

How to Upload Large Files to GitHub | Git LFS

Introduction


In this brief article, I will cover the basics of Git Large File System, short for Git-LFS.

Purpose/Use Case

Its use case is, as the name suggests, to allow uploading large files (over 100 MB – to be precise) to your GitHub Repository. You might need to push design files to your repository (for documentation purposes, or to keep everything related to a project in one place), or you might be a game developer, in which case, there are dozens of files with a size that is north of the limit.

How it Works – Theory

In essence, the large files are still not stored within the GitHub repository. Git-LFS works by uploading the large files to the cloud and store a pointer with the location of that file in your GitHub Repository.

Installation

brew install git-lfs # for mac

https://docs.github.com/en/github/managing-large-files/installing-git-large-file-storage

Commands to know

  1. If you do not wish to add the large files to your GitHub repository, you can simply add them to the .gitignore file. As a basic example, let us say you wish to prevent all the zip files in your local repository from being tracked/uploaded to the remote repository, you would add the following line in your .gitignore file:
*.zip
  1. If you do wish to track the large files, then you can either add those files individually or in bulk. The bulk is particularly useful when most of your files over 100 MB are divided into a few different extensions. For instance, you might have 15 PSD files and 10 zip files.

Steps

  1. Navigate to the project directory in terminal/command prompt and run the below commands:
git lfs install
git lfs track *.psd
  1. That’s it. Add, commit and push your changes to the remote repository like you normally would and the error won’t appear.
Exit mobile version