According to Tomiwa, Git and GitHub are two symbiotic tools for developers. Git on one hand is a version control tool (like a file's registry) used to keep track of a particular codebase and all it's history right from initiation, this helps you manage the code base, ensure seamless versioning (eg v1, v2...)
GitHub on the other hand is a cloud hosting system designed to help maintain all your git repository, thus the term 'symbiotic'.
To push your project to GitHub after coding
Requirements:
- An established project on your local disk
- Install Git on the PC (you can install Git by downloading from http://git-scm.com).
Steps:
- Open git bash and navigate to the folder where the files you want to push are. Then initialize git
git init
- Add your files
git add .
It automatically adds all the files in that folder to git and it will be able to track them.
- Commit your files with a custom message. It will commit and notify git that you want to push these files online. Make your commit message as descriptive as possible.
-git commit -m "Custom Message"
- Add your Github repository as a remote
git remote add origin git@github.com:User/UserRepo.git
where User is your username and UserRepo is your repository name.
- Push your code to GitHub. This means you are pushing to a branch named 'main' on a remote repository on Github
-git push origin main
Top comments (5)
Before you can 'git add' you'll need to initialise the repository with 'git init'
Also, before you can push your repository to GitHub or anywhere else, you'll need to add it as a remote.
I wouldn't say 'Push your code to Git', that doesn't really make sense. You push some branch/tag/refspec to another repository, it could be a repository local to your machine, or remote, like GitHub, GitLab etc or just your own hosted repository perhaps using git-daemon.
Thank you very much, Andrew. I have corrected the article to reflect this. Compliments of the season to you
The article doesn't talk about creating ssh keys...if this article is directed at beginners, I think they'll have a problem pushing their project to GitHub for the first time
Boss when should we be expecting more
Sooon. I'm trying to get back in the groove of writing