Quick GitHub and GitBash Basics for Beginners Tutorial

Quick-GitHub-and-GitBash-Basics-for-Beginners-tutorials-commands-.jpg September 13, 2016 97 kB 622 × 450 Edit Image Delete Permanently URL http://vastinfos.com/wp-content/uploads/2016/09/Quick-GitHub-and-GitBash-Basics-for-Beginners-tutorials-commands-.jpg

GitHub is the best platform for version control, collaborative works and code sharing. Coding beginners can practice using GitHub by pushing their everyday coding exercise works to the repository. For beginners who want to quickly learn and start using GitHub may find difficult to reach out to the exact quick basic lessons, since there are lots of GitHub tutorials which are very detailed. So if you are looking to learn GitHub and GitBash terminal basics – Quick GitHub and GitBash Basics for Beginners tutorial will definitely gonna help you.

 Quick-GitHub and GitBash Basics for Beginners tutorials-commands-.jpg September 13, 2016 97 kB 622 × 450 Edit Image Delete Permanently URL http://vastinfos.com/wp-content/uploads/2016/09/Quick-GitHub-and-GitBash-Basics-for-Beginners-1-tutorials-commands-1-11-1.jpg

Quick GitHub and GitBash Basics for Beginners Tutorial

You can use GitHub desktop client or GitBash terminal for interacting with your GitHub repositories.

So here are tools you need basically for setup:

Setting Up GitHub account with GitBash

  • Add your details to git for introducing yourself with the set of commands

git config –global user.name “Your Name

Replace Your Name  with your username.

git config –global user.email “example@youremail.com

Replace example@youremail.com with your email which you used to sign up on GitHub.

How to use GitHub and GitBash

quick-github-and-gitbash-basics-for-beginners

quick-github-and-gitbash-basics-for-beginners-creating-repository

  • Now you will get the URL of the newly created project’s git file.

eg: https://github.com/username/MS_App.git

Where username will be the GitHub username and MS_App is the project repository name in my case.

Copy this and it will be used later.

  • Next step is to create a folder on your local disk like C drive or other drives, you can name the folder for eg: github
  • After creating the folder , Open the GitBash terminal
  • Go to the folder you have created using the Linux commands like,

cd  c:/

cd github

Now we have reached the folder through the Git Bash terminal.

git bash terminal folder or directory commands basics c drive

  • Next step is to clone the project folder of the repository which we have created on our GitHub account, for this type the command on GitBash terminal

git clone https://github.com/username/MS_App.git

Replace the above URL (https://github.com/username/MS_App.git) with the URL you have copied from your GitHub repository

  • After typing the above command, you will get the message that:

          You have successfully cloned to an empty repository.

You can confirm it by typing command:

ls

You will find the project/repository folder there. Here in my case, the project folder name is MS_App. So next I have to open the folder through the GitBash terminal. For that I’m using the command:

cd MS_App

Replace MS_App with your project folder/repository name in the above command.

Now we are successfully done with the initial step that is setting up the project folder in local disk.

Next is to start working on the project, adding the project files, commit the changes and finally pushing to the GitHub cloud project repository.

pulling-or-clonning-github-project-files-using-git-bash

As of now our project folder is locally stored on the local drive C and the location is,

C://github/MS_App

Open this folder using windows File Explorer, you can find the folder only contains one hidden folder named .git, there won’t be any other files other than this hidden folder. All the tracking details regarding the changes made to the project are stored in this .git folder.

  • To know the status of the project, you can type in the following command on the Git Bash terminal

git status

If the response is nothing to commit, means there new changes on the project.

  • Next, add a project file to this folder.

I’m adding an HTML file (welcome.html) to my folder. Now again check the status of your project using command:

git status

Now you can see, the newly created file in red color.

  • Add the newly created file before committing, using the add command:

git add welcome.html

The above command adds only one file called welcome.html, if there are multiple files/folders to be added, you can use the below command,

git add .

Now your newly created project files are successfully added to tracking.

  • Next is to commit the changes added to the project, for the use the commit command and a commit message as the log message for the current commit.

For the first commit, you can add commit message as the initial commit .  For later commit, you can use messages like, added a change to welcome file or fixed this bug etc.

git commit -m “Initial commit, added welcome page file”

  • And the final step is to push the committed changes to GitHub Cloud. For that use the command

git push

If may ask for your GitHub username and password for accessing your GitHub account and pushing the project files to it.

If the above push command shows error, you can try the below command,

git push https://github.com/username/MS_App.git

Replace https://github.com/username/MS_App.git with the URL you have copied earlier.

Quick GitHub and GitBash Basics for Beginners -add-commit-push-commands-tutorial

This is the Quick GitHub and GitBash Basics for Beginners , I have covered few basic commands to be used on Git bash terminal for interacting with your GitHub cloud. GitHub can be used for doing collaborative works and version control.

Other Commands:

  • Command to specify the GitHub repository,

git remote add origin https://github.com/username/MS_App.git

Replace https://github.com/username/MS_App.git with the URL you have copied earlier.

  • Command to verify the repository to which the GitBash is connected for interaction,

git remote -v

 

If you face any difficulties with these basics, kindly comment on this post. I believe this post could help you to successfully try out GitHub for the first time. If you want to learn deep on GitHub, you can find lots of detailed tutorials. By the time I will be back with the next part of the Quick GitHub and GitBash Basics for Beginners tutorial.

You May Also Like

About the Author: Sreeraj Melath

One Comment to “Quick GitHub and GitBash Basics for Beginners Tutorial”

Comments are closed.