Ultimate Beginner’s Guide to GitHub with Git bash

Comprehensive steps with concept and terminology explanations from scratch.

Ishika Johari
6 min readFeb 18, 2022
Photo by Jamie Street on Unsplash

Contents

  1. What are GitHub and Git really?
  2. Installation
  3. Steps to create a new repository on GitHub
  4. Pushing New Changes to GitHub
  5. Basic Git Lingo

Since the dawn of the software development era, Git has and will continue to be one of the most necessary version controlling tools (what developers use to save all relevant versions of their work to avoid forgetful moments) a developer or even a Travel blogger (this article by ReadWrite might be insightful) might come across.

What’s GitHub then, you might ask?

Well, in simple terms Git (Official Site) is software, while GitHub (Official Site) is the GUI (Here’s a list of more GUIs) through which you use said software.

Apart from these other GUIs linked above, there are a few options when it comes to using GitHub.

  • GitHub Desktop
  • GitHub Bash

If you ask me, my personal preference is the latter. If you are someone who likes to learn the concepts and in general would like to benefit in the long run, then I suggest you do the same.

I’m writing this article as much for myself as I am for those who time and again, find themselves googling, “Git vs GitHub”, “Steps to use GitHub” or “How to upload/offload to/from Github?”. Upon a bit of searching and surfing around, these are the steps I now blindly follow whenever I need to push, fork or pull from or to GitHub using GitHub bash.

The following figure shows you the structuring of Git and defines how the Working Tree, Staging Area and Repository connect and function together. This will come in handy later.

How Git Works

Installation

For Windows users: Download Git bash from the official site here. Upon running the .exe file and following the instructions, right-click on your project folder and click “Git Bash Here”

For Mac/Linux Users: After making sure that you’ve installed git, open your Terminal application and navigate to the directory of your project.

NOTE: Among the following commands:
* - You can use this command anytime throughout
*** - It’s optional to use this command

Steps to create a New Repository on GitHub

Step 1:

Go to your GitHub account after creating one, and open a new repository from the upper right corner of the main page.

Open a new repository from the upper right corner

Leave the Add README file option unchecked (to not overcomplicate things as of now). After filling in the details, click on the Create Repository button.

On the Quick setup page, copy the repository link for later.

Sample repository link:

 https://github.com/your_username/your_project_repo_name.git

Step 2:

In the git bash terminal/command prompt (depending on the OS of your computer), navigate inside your project directory and initialize a new git repository by typing -

git init

Use the status command at any point during the further process to check the status -

git status *

Step 3:

Now’s the time to use the link we copied while the repo creation.

git clone <- URL_of_cloned_or_main_repo ->

After this, you’ve successfully created a link between your project files on your system and the repository you created.

Now you can work on it however you seem fit.

Pushing New changes To GitHub

Step 1:

git add .

This will add the changes or updates you made to the Staging Area.

Step 2: *

As always you can use this to check where you’re at.

git status

Step 3:

git commit -m "<- commit_message ->"

This will commit the changes or updates you made to the Repository.

Step 4:

git remote add <- origin [you’ll name it here] -> <- url_of_the_repo (same for all branches) ->

(This step is only needed for the first time when you push changes)

Step 5: ***

git remote -v (To check)

Step 6: ***

git checkout -b <- new_branch_name [gets creates here] -> ***(dont do if main)

Step 7:

git push <- origin (the one you previously named in step 3) -> <- new_branch_name (the one it gets pushed in) / master ->

If you liked this, please clap 👏 and share!

Basic Git Lingo

  1. add: To add either a single, multiple or all (used by “.”) files to the Staging Area.
  2. commit: To record and store the changes made from the Staging Area into the Repository. Each commit has a unique ID and is essentially a snapshot of the repo at a certain point in time. It’s best to always make a commit with a message specifying the exact changes that were made for later reference and convenience.
  3. remote: This is the repository where all the collaboration happens. It’s the one that’ll be stored in a code hosting service such as GitHub.
  4. local: This is the repository that is stored on your computer and work on this can be done offline as well (depends on the project, but generally yes).
  5. push: When suppose you have to update changes you made locally on a directory linked to a repo, and you need to update those changes to your GitHub profile or quite literally “push” those changes.
  6. pull: When you bring back updates to the Github repository to your local directory. This happens when suppose a collaborator made some changes to the GitHub repo in the meanwhile and you need to sync the work.
  7. fetch: “git fetch” is the command to use when you need to check which or if changes were made at all to the remote repository. It doesn’t actually include any file transferring, which is where it differs from doing a “pull”.
  8. clone: To create a directory locally of an existing remote repo (maybe just created, like what we see in Step 3 when creating a new or pre-existing project).
  9. fork: Forking means to create a clone of somebody else’s repository (from a certain branch if more than one present), copying their work till that point of time, to a new repository.
  10. branch: It is an alternate version of your repository and contains the work done until the split was created. Branches may be created when every team member has different work to do so they can create their own respective branches. It is a way for each person in a team to create a temporary clone for tandem editing and then push those updates back to the group project again.
  11. checkout: “git checkout” is the command to use to switch to a different branch. It updates the files in the repository to match the ones in this specific branch.
  12. merge: When you need to merge the work from one branch to another. This may be done when suppose, you started a new branch to explore some alternative paths to your project and now want to merge it into the main one.
  13. pull request: Consider a situation where you forked a repository to work upon the work and add some things on. Now you want these changes to be incorporated into the original existing repository and thus you create a pull request to discuss and review the potential updates you made.

Resources:

  1. https://readwrite.com/seven-ways-to-use-github-that-arent-coding/
  2. https://git-scm.com/
  3. https://github.com/
  4. https://git-scm.com/downloads/guis
  5. https://www.quora.com/What-are-the-advantages-of-using-Git-Bash-over-Git-Desktop
  6. https://git-scm.com/download/mac
  7. https://www.macworld.com/article/221277/command-line-navigating-files-folders-mac-terminal.html
  8. https://frontendmasters.com/courses/git-in-depth/working-area-staging-area-repository/#:~:text=These%20files%20are%20also%20referred,all%20of%20a%20project's%20commits.
  9. http://guides.beanstalkapp.com/version-control/common-git-commands.html
  10. https://youtube.com/playlist?list=PLozRqGzj97d02YjR5JVqDwN2K0cAiT7VK by Daniel Shiffman

--

--

Ishika Johari

Data Science Analyst @ Dell Technologies | Steadfast Learner | Just a tyro at Data Science