Git is a distribution version control system that multiple developers use to work on a project.
GitHub is a cloud platform that uses Git as its core technology.
To create a code and push it to GitHub using Git bash. Here is a step-by-step process.
- Open your git bash terminal and enter your details using the following commands git config --global user.name "your username" git config --global user.email "your GitHub email"
- cd ~ and create a directory (folder) using the command mkdir mkdir "directory name"
- Enter into the directory you create using the cd command cd "directory name"
- Then initialize your master branch by running the command git init
- Create a file name index.html by running the command touch index.html
- To input the html code in the file run the command vi index.html, a new page will open, paste the code you have copied or write your own code and exit with the escape (esc) botton, save and quit the command :wq
- To check the content of the file run the cat command cat index.html
- Open your GitHub account on a browser in order to create a repository.
- Click on the icon that has your profile picture and click on repository.
- Click on New and give your repository a name, make sure it is Public. check the Readme box and click on create repository 11.Once is done you will see a green icon with the name Code, click on it and copy the https URL.
- Go back to Git bash and run the command git remote add origin " paste the URL" you copied, and press enter.
- To add your code on run the command git add index.html.
- To check if the file was actually added in your git run the command git status
- Now let's add a commit message using the command git commit -m " add any message of your choice", check the status again 16.Next input the major command to push your code, run the command git push origin master and press enter. 17.Now let's go to GitHub to see if truly we have successfully pushed. Click on the repository you created.
- Next click on main, and then click on master branch, you see the index.html, click on it to see the code you pushed. Attached is the screenshot of the above steps.
Top comments (0)