In the previous blog, you have gone through Git and its purpose and also about github.
In this blog, I shall take you through the journey of git commands and how the existing source code is pushed to remote web repository.
here are few git commands which we shall look into in details
git init //only for a first time
git add . // only when files to be added for stagging
git commit -m “your meaningful message”
git remote add origin <url>
git push origin master
The following two commands are being used for one time while setting up the git environment in your laptop/desktop
git config –global user.email “your@email.com”
git config –global user.name “your name”
–global (is used to make sure that the user.email and user.name is available everywhere within the system)
Below are the steps(along with screenshots ) u need to follow for pushing your source code to GitHub.
Step 1. here we create a new directory/folder using mkdir command.

Step 2. using cd command, we moved to the newrepo folder.

Step 3. Using git init command, we initialized the newrepo folder as git repository.

Step 4. We created or copied two files inside the newrepo folder. Using ls command, we can list the files inside the folder.

Step 5. Using git add . command, we added the files inside the newrepo folder for staging.
Step 6. git status command shows the staged files which have been added.

Step 7. Using git commit -m “techdenovo and techdenovo_images files added” command, we saved the state of the stage containing the files.

Step 8.  Next, we goto the URL of GitHub  (https://github.com) and log into the GitHub dashboard and create a new repository.

Step 9. The remote(GitHub) repository name should be same as the local repository name.

Step 10. We choose Public access to the repository and create the repository.

Step 11. Since we already have our existing repository, we shall only use “git remote add origin https://github.com/kalyan4github/newrepo.git ” and “git push – u origin master” in the git bash.

Step 12. “git remote add origin https://github.com/kalyan4github/newrepo.git” command is used to link the local repository to the remote repository and giving the URL (https://github.com/kalyan4github/newrepo.git) a name of “origin”.

Step 13. Then we use “git push -u origin master” command to push our source codes to GitHub remote repository. It will prompt for GitHub username:

If you are doing this for the very first time, you will have to use git config command and then commit the changes as follows:

Step 14. As soon as the username is entered, it will prompt for a password.

Step 15. Entering correct credentials will start the push process.

Step 16. Then we goto the GitHub repository (newrepo) and verify the Source code we have pushed.

In the upcoming blog, I shall cover topics related to git which will show the collaboration of developers within the same repository. Also, stay tuned for the video blog of this article.

Leave Comment