We have seen before how to clone a remote repository to local, work on it, modify files, commit and push to remote repository. But most of the time what happens we have a project on local (a new one) and want to save it on github. In this post we will see how to do that.
Pushing existing local project to Github
You will need to initialize a new repository on Github first. Simple create an empty repository.
Now to add your local repo you can execute following commands -
- mkdir MyTestRepo
- cd MyTestRepo/
- touch test.txt
- git init
- git add .
- git commit -m "First commit"
- git remote add origin https://github.com/aniket91/MyTestRepo.git
- git push -f origin master
Output is as follows -
You can then see this commit on remote.