How to Upload a Local Git Repository to Github

GitHub is but a cloud-hosted Git management tool. Git is distributed version command, pregnant the unabridged repo and history lives wherever you put information technology. People tend utilize GitHub though in their business organisation or development workflow as a managed hosting solution for backups of their repositories.

It's a convenient and by and large worry-gratuitous method for backing up all your code repos. Information technology also allows yous to very nicely navigate and view your lawmaking on the spider web. GitHub takes this even further past letting yous connect with coworkers, friends, organizations, and more than.

Prerequisites:

To initialize the repo and push information technology to GitHub you'll need:

  1. A complimentary GitHub Account
  2. git installed on your local car

Step 1: Create a new GitHub Repo

Sign in to GitHub and create a new empty repo folio. You tin cull to either initialize a README or not. It doesn't really matter because we're just going to override everything in this remote repository anyways.

Create new GitHub Repo

Through the rest of this tutorial we'll assume your GitHub username is sammy and the repo y'all created is named my-new-projection (So you'll need to swap those out with your actual username and repo proper name when re-create/pasting commands)

Footstep ii: Initialize Git in the projection folder

From your concluding, run the following commands afterwards navigating to folder you would like to add together:

Initialize the Git Repo

Make sure you are in the root directory of the projection you want to push button to GitHub and run:

Note: if you already take an initialized Git repository, yous can skip this control

                      
  1. git init

This pace creates a hidden .git directory in your project folder which the git software recognizes and uses to store all the metadata and version history for the projection.

Add together the files to Git index

                      
  1. git add -A

The git add together control is used to tell git which files to include in a commit, and the -A argument ways "include all".

Commit Added Files

                      
  1. git commit -m 'Added my project'

The git commit command creates a new commit with all files that have been "added". the -m 'Added my project' is the message that will exist included alongside the commit, used for hereafter reference to understand the commit.

Add new remote origin (in this case, GitHub)

                      
  1. git remote add origin git@github.com:sammy/my-new-projection.git

Notation: Don't forget to replace the highlighted bits higher up with your username and repo name.

In git, a "remote" refers to a remote version of the same repository, which is typically on a server somewhere (in this case GitHub.) "origin" is the default name git gives to a remote server (you tin can have multiple remotes) so git remote add origin is instructing git to add the URL of the default remote server for this repo.

Push button to GitHub

                      
  1. git button -u -f origin main

With this, there are a few things to note. The -f flag stands for strength. This will automatically overwrite everything in the remote directory. Nosotros're simply using it hither to overwrite the README that GitHub automatically initialized. If you skipped that, the -f flag isn't really necessary.

The -u flag sets the remote origin as the default. This lets you later on hands but exercise git push and git pull without having to specifying an origin since we always want GitHub in this case.

All together

                      
  1. git init
  2. git add together -A
  3. git commit -m 'Added my project'
  4. git remote add origin git@github.com:sammy/my-new-project.git
  5. git push -u -f origin principal

Conclusion

Now y'all are all set to track your lawmaking changes remotely in GitHub! Equally a adjacent step here's a complete guide to how to apply git

Once you start collaborating with others on the project, you'll desire to know how to create a pull request.

guptacrigoithave.blogspot.com

Source: https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github

0 Response to "How to Upload a Local Git Repository to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel