How to Upload in a Given Repository Using Cmd
GitHub is but a cloud-hosted Git management tool. Git is distributed version control, meaning the entire repo and history lives wherever y'all put it. People tend use GitHub though in their concern or evolution workflow every bit a managed hosting solution for backups of their repositories.
It's a convenient and mostly worry-free method for backing upwards all your code repos. Information technology also allows you to very nicely navigate and view your lawmaking on the web. GitHub takes this even further by letting you connect with coworkers, friends, organizations, and more than.
Prerequisites:
To initialize the repo and button 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 tin cull to either initialize a README or not. It doesn't really affair considering we're simply going to override everything in this remote repository anyways.
Through the rest of this tutorial we'll assume your GitHub username is sammy
and the repo you created is named my-new-project
(So 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 lot 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:
Note: if yous already have an initialized Git repository, you can skip this control
- git init
This stride creates a hidden .git
directory in your project binder which the git
software recognizes and uses to store all the metadata and version history for the projection.
Add the files to Git index
- git add together -A
The git add together
command is used to tell git which files to include in a commit, and the -A
argument means "include all".
Commit Added Files
- git commit -grand '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 aslope the commit, used for time to come reference to empathise the commit.
Add together new remote origin (in this case, GitHub)
- git remote add origin git@github.com:sammy/my-new-project.git
Note: Don't forget to supervene upon 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 instance GitHub.) "origin" is the default proper noun git gives to a remote server (you can have multiple remotes) 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 chief
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 information technology 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 lot later hands simply do git push
and git pull
without having to specifying an origin since we always want GitHub in this case.
All together
- git init
- git add -A
- git commit -m 'Added my project'
- git remote add origin git@github.com:sammy/my-new-projection.git
- git button -u -f origin chief
Conclusion
At present y'all are all ready to rails your lawmaking changes remotely in GitHub! Equally a adjacent step here's a consummate guide to how to use git
One time you start collaborating with others on the project, y'all'll desire to know how to create a pull request.
pettigrewprephred.blogspot.com
Source: https://www.digitalocean.com/community/tutorials/how-to-push-an-existing-project-to-github
0 Response to "How to Upload in a Given Repository Using Cmd"
Post a Comment