How to Upload Code to Github Mac
GitHub is simply 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 utilise GitHub though in their business or development workflow as a managed hosting solution for backups of their repositories.
It's a convenient and more often than not worry-free method for backing up all your lawmaking repos. It also allows you to very nicely navigate and view your code on the web. GitHub takes this even further by letting yous connect with coworkers, friends, organizations, and more.
Prerequisites:
To initialize the repo and push it to GitHub you'll need:
- A free GitHub Account
-
git
installed on your local machine
Step 1: Create a new GitHub Repo
Sign in to GitHub and create a new empty repo page. You can cull to either initialize a README or not. It doesn't really matter because we're only going to override everything in this remote repository anyways.
Through the residuum of this tutorial we'll assume your GitHub username is sammy
and the repo yous created is named my-new-project
(Then yous'll need to bandy those out with your bodily username and repo name when re-create/pasting commands)
Footstep 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 are in the root directory of the project you want to push to GitHub and run:
Notation: if you already accept an initialized Git repository, you can skip this command
- 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 project.
Add the files to Git index
- git add -A
The git add
control is used to tell git which files to include in a commit, and the -A
argument means "include all".
Commit Added Files
- git commit -k 'Added my projection'
The git commit
control creates a new commit with all files that have been "added". the -1000 'Added my projection'
is the message that will exist included alongside the commit, used for hereafter reference to understand the commit.
Add new remote origin (in this instance, GitHub)
- git remote add together origin git@github.com:sammy/my-new-project.git
Note: 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 instance GitHub.) "origin" is the default proper noun git gives to a remote server (you can take multiple remotes) and so git remote add together origin
is instructing git to add the URL of the default remote server for this repo.
Push to GitHub
- git push -u -f origin master
With this, there are a few things to notation. The -f
flag stands for strength. This volition automatically overwrite everything in the remote directory. We're just using information technology 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 as the default. This lets you later on easily simply do git push
and git pull
without having to specifying an origin since nosotros always want GitHub in this case.
All together
- git init
- git add -A
- git commit -k 'Added my project'
- git remote add origin git@github.com:sammy/my-new-project.git
- git push -u -f origin principal
Conclusion
Now you are all gear up to runway your lawmaking changes remotely in GitHub! As a next step hither'south a complete guide to how to use git
Once you start collaborating with others on the project, you'll want to know how to create a pull request.
Source: https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github
0 Response to "How to Upload Code to Github Mac"
Post a Comment