How to Upload Already Initilized Git Project to Github
GitHub is but a cloud-hosted Git management tool. Git is distributed version command, meaning the entire repo and history lives wherever y'all put it. People tend use GitHub though in their business or development workflow as a managed hosting solution for backups of their repositories.
It's a convenient and mostly worry-free method for backing upwardly all your lawmaking 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 information technology to GitHub you lot'll need:
- A gratuitous GitHub Account
-
gitinstalled on your local motorcar
Step 1: Create a new GitHub Repo
Sign in to GitHub and create a new empty repo page. You can choose to either initialize a README or not. Information technology doesn't actually matter considering we're just going to override everything in this remote repository anyways.
Through the remainder of this tutorial we'll presume your GitHub username is sammy and the repo you created is named my-new-project (And then you'll demand to swap those out with your actual username and repo name when copy/pasting commands)
Step 2: 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 lot 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, you lot can skip this command
- 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 the files to Git alphabetize
- git add -A
The git add command is used to tell git which files to include in a commit, and the -A statement means "include all".
Commit Added Files
- git commit -1000 'Added my project'
The git commit command creates a new commit with all files that have been "added". the -m 'Added my projection' is the bulletin that will be included alongside the commit, used for futurity reference to understand the commit.
Add together new remote origin (in this case, GitHub)
- git remote add together origin git@github.com:sammy/my-new-project.git
Note: Don't forget to supplant the highlighted $.25 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 (you can have multiple remotes) and so git remote add origin is instructing git to add the URL of the default remote server for this repo.
Push button to GitHub
- git push -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. Nosotros'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 you later easily just do git push and git pull without having to specifying an origin since we ever want GitHub in this case.
All together
- git init
- git add -A
- git commit -m 'Added my project'
- git remote add together origin git@github.com:sammy/my-new-project.git
- git push -u -f origin master
Decision
At present you are all set to rail your code changes remotely in GitHub! As a next pace here's a complete guide to how to use git
Once you kickoff collaborating with others on the project, you'll want to know how to create a pull asking.
campbellmepheculd.blogspot.com
Source: https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github
0 Response to "How to Upload Already Initilized Git Project to Github"
إرسال تعليق