How to Push an Existing Project to GitHub
source link: http://adnjavainterview.blogspot.com/2019/09/how-to-push-existing-project-to-github.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
How to Push an Existing Project to GitHub
In daily basis developer work is to do code check in, check out, pull, fetch and so on. But in the current post, we will learn how to push the existing local project to GitHub
repository.
For example:- I have a project EmployeeManagement(EMS) in my local but no one can able to access or modify code without creating and pushing code to GitHub repository.
The steps to push local project to GitHub repository as follows,
1) Create a repository on GitHub.
Create a GitHub account if you don't have.
Then Go to Account --> Your repositories
Click on New as shown in below screenshot.
When click on New button, will open Create New Repository page.
Create Repository
Provide repository name(Usually project name)
Select public or private repository option
To avoid errors, do not initialize the new repository with README,
license, or gitignore files. You can add these files after your project has been pushed to GitHub.
Click on Button/action ""Create repository"
2) Initialize the local directory as a Git repository.
Change the current working directory to your local project and then initialize the local directory as a git repository using command "git init"
e.g your project directory is C:\\ProjectRepo\EMS
then
C:\ProjectRepo\EMS>git init
Add files to the GitHub,
C:\ProjectRepo\EMS>git add .
C:\ProjectRepo\EMS>git add "file path to add to git"
4) Commit the files that you've staged in your local repository.
Use command - git commit -m "First commit" to commit the added file to gitHub.
C:\ProjectRepo\EMS>git commit -m "First commit"
Copy below HTTPS or SSH Project URL
Remote Repo HTTPS o SSH URL
In the Command prompt, add the URL for the remote repository where your local repository will be pushed.
>git remote add origin "remote repository URL"
C:\ProjectRepo\EMS>git remote add origin "remote repo HTTPS or SSH URL"
Using git push command, you can the committed files to the remote repository as follow,
C:\ProjectRepo\EMS>git push origin master
Related Post:--
Permission denied(publickey), fatal:couldn't read from remote repository - Gihub Error
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK