Cli Make and Upload Directory to Github

GitHub is simply a cloud-hosted Git management tool. Git is distributed version control, meaning the entire repo and history lives wherever you put it. People tend use GitHub though in their business organization or evolution workflow every bit a managed hosting solution for backups of their repositories.

It'southward a convenient and mostly worry-costless method for bankroll upwardly all your code repos. It as well allows yous to very nicely navigate and view your code on the spider web. GitHub takes this even further by letting you connect with coworkers, friends, organizations, and more than.

Prerequisites:

To initialize the repo and push button it to GitHub you'll demand:

  1. A gratis GitHub Business relationship
  2. git installed on your local machine

Step 1: Create a new GitHub Repo

Sign in to GitHub and create a new empty repo folio. Yous can choose to either initialize a README or not. It doesn't actually matter because nosotros're just going to override everything in this remote repository anyways.

Create new GitHub Repo

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

Pace 2: Initialize Git in the projection folder

From your terminal, run the post-obit commands later navigating to folder you would like to add:

Initialize the Git Repo

Brand sure you are in the root directory of the projection you desire to button to GitHub and run:

Annotation: if y'all already have an initialized Git repository, you tin skip this command

                      
  1. git init

This step 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 the files to Git index

                      
  1. git add together -A

The git add 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 volition be included alongside the commit, used for futurity reference to understand the commit.

Add new remote origin (in this case, GitHub)

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

Note: Don't forget to supplant 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 (yous tin can accept multiple remotes) so 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 button -u -f origin master

With this, there are a few things to note. The -f flag stands for force. This volition automatically overwrite everything in the remote directory. We're only using it here 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 yous later easily merely do git push button 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 -thousand 'Added my project'
  4. git remote add origin git@github.com:sammy/my-new-project.git
  5. git push -u -f origin master

Conclusion

Now you are all ready to track your code changes remotely in GitHub! As a next pace here's a complete guide to how to utilise git

Once yous beginning collaborating with others on the project, you lot'll want to know how to create a pull asking.

loughmanbuied1993.blogspot.com

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

0 Response to "Cli Make and Upload Directory to Github"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel