GitHub is a provider of internet hosting for software development and version control using Git. It is also a publishing tool and a great way to collaborate with others. Github gives us the ability to save our process and go back to earlier points as needed.
We can push code to Github following these steps;
Before we can push code to Github, Git needs to to be installed on your computer, start by heading to the Git website and downloading the latest version. Follow the steps provided on the website and install Git on your computer.
After installing Git, open Github and confirm that you are signed in, click on Create new repository and then add a name and description
After creating a new repository, a quick setup page is loaded which has important information on how to push your code to the repository using the terminal
Next open the terminal and set your local project as the working directory by typing cd
followed by the path of the folder where your project is saved on your computer and hitting return. The files in the directory can be viewed by typing ls
and hitting return.
Intialize your local directory as a git repository by typing git init
and hitting return
Add the files in your local repository to the git repository by typing git add .
and hitting return.This stages the files for commit. Typing git status
and hitting return shows us the files that have been staged to commit
Commit the files you have staged by typing git commit -m “first commit”
and hitting enter.The -m flag specifies what commit message will be recorded in the repository. This is purely informational to users. The message might be “fixed bug,” “new level,” etc. This message helps other developers easily know what changes have been made to the code.
Specifying the remote repository’s url comes next and to do this copy the url from the Github repository quick setup page then in terminal type git remote add origin
, paste the Git repository’s url and hit return.
Finally, push the code in your local repository by typing git push -u origin master
and hit return. Enter your Github username and password when requested.
Once all these steps are completed, the files from your local directory will be added to your repository on Github
Top comments (0)