How to Upload Your Project to Existing Repository Using Git Bash
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 information technology. People tend utilize GitHub though in their business organization or evolution workflow as a managed hosting solution for backups of their repositories.
It's a convenient and by and large worry-complimentary method for backing upward all your lawmaking repos. It also allows you to very nicely navigate and view your lawmaking on the web. GitHub takes this even further past letting y'all connect with coworkers, friends, organizations, and more.
Prerequisites:
To initialize the repo and push button information technology to GitHub you lot'll need:
- A free GitHub Account
-
gitinstalled on your local machine
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. It doesn't actually matter because we're just going to override everything in this remote repository anyways.
Through the balance 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 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 certain y'all are in the root directory of the projection you want to push to GitHub and run:
Annotation: if you already have an initialized Git repository, you can skip this command
- git init
This step creates a hidden .git directory in your projection 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
- 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
- git commit -thou 'Added my project'
The git commit control creates a new commit with all files that have been "added". the -m 'Added my project' is the message that will be included aslope the commit, used for time to come reference to empathise the commit.
Add new remote origin (in this case, GitHub)
- git remote add origin git@github.com:sammy/my-new-projection.git
Note: Don't forget to replace the highlighted $.25 to a higher place with your username and repo proper 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 origin is instructing git to add the URL of the default remote server for this repo.
Push to GitHub
- git push button -u -f origin master
With this, in that location are a few things to notation. The -f flag stands for strength. This will automatically overwrite everything in the remote directory. We're only using it hither to overwrite the README that GitHub automatically initialized. If yous skipped that, the -f flag isn't really necessary.
The -u flag sets the remote origin as the default. This lets you later easily but practise git push and git pull without having to specifying an origin since nosotros ever want GitHub in this case.
All together
- git init
- git add -A
- git commit -1000 'Added my projection'
- git remote add origin git@github.com:sammy/my-new-project.git
- git push -u -f origin master
Conclusion
Now y'all are all set to rails your code changes remotely in GitHub! As a side by side footstep hither's a complete guide to how to use git
Once y'all showtime 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 Your Project to Existing Repository Using Git Bash"
Post a Comment