How to Upload Exisiting Repository to Github

GitHub is simply a deject-hosted Git management tool. Git is distributed version command, significant the unabridged repo and history lives wherever yous put it. People tend utilize GitHub though in their business or development workflow as a managed hosting solution for backups of their repositories.

It'due south a user-friendly and mostly worry-free method for bankroll up all your code repos. It also allows yous to very nicely navigate and view your code on the web. GitHub takes this even further by letting you connect with coworkers, friends, organizations, and more.

Prerequisites:

To initialize the repo and push it to GitHub y'all'll need:

  1. A free GitHub Account
  2. git installed on your local machine

Step i: Create a new GitHub Repo

Sign in to GitHub and create a new empty repo page. You lot can choose to either initialize a README or non. Information technology doesn't really matter because we're simply going to override everything in this remote repository anyways.

Create new GitHub Repo

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

Step two: Initialize Git in the project folder

From your terminal, run the following commands after navigating to folder you would like to add:

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 have an initialized Git repository, yous can skip this control

                      
  1. git init

This footstep 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 project.

Add together the files to Git index

                      
  1. git add -A

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

Commit Added Files

                      
  1. git commit -thousand '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 be included alongside the commit, used for time to come reference to sympathise the commit.

Add new remote origin (in this case, GitHub)

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

Annotation: Don't forget to replace the highlighted bits above 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 (y'all tin have multiple remotes) and then git remote add origin is instructing git to add the URL of the default remote server for this repo.

Push to GitHub

                      
  1. git push -u -f origin master

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

The -u flag sets the remote origin equally the default. This lets yous after easily merely do 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 -A
  3. git commit -yard 'Added my project'
  4. git remote add origin git@github.com:sammy/my-new-project.git
  5. git push -u -f origin master

Determination

Now you are all prepare to rail your lawmaking changes remotely in GitHub! As a adjacent step hither's a complete guide to how to apply git

In one case you lot start collaborating with others on the project, you'll want to know how to create a pull request.

boozerwrond1963.blogspot.com

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

0 Response to "How to Upload Exisiting Repository to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel