DEV Community

Cover image for GIT *BASH *& GITHUB
FLORENCE MBUTHIA
FLORENCE MBUTHIA

Posted on

GIT *BASH *& GITHUB

GIT AND GITHUB
Git is a distributed version control tool that track changes into files or code and we can say it works offline.

A version control is system used to track and manage changes to a remote file in git.

Git Bash is born again shell or basically a command prompt window which emulates UNIX and LINUX environments.

Git hub is a website that stores your Git repositories in the cloud so we can say it exist online.It stores your project's version history online and adds collaboration tools like pull requests, issue tracking, and code review."
_A repository _in GitHub is similar to a folder in your local machine so any changes are tracked.

How to create a repository in GitHub do a simple README.md(markdown) then commit the file and write a massage inside to describe the changes done,then we will need to download a visual code eg VScode where you are able to access the terminals.

Git is used to push changes** to git hub or pull a repo from GitHub**

There are 3 states that every files lives in;

  1. Working Directory-You have made changes but git has not recorded them yet.(it's still on our machine)

  2. Staging Area -You have told Git about the changes. Not saved yet. git add filename thus we git add

  3. Repository (.git)-Changes are permanently saved in history. git commit -m "message"

*Basic Commands/key terms used *

  • git config allows git to know who you are by using your username and user email e.g. your GitHub account name and email address this is an important info when you want to commit changes as it will tell you who made the changes there are different levels but we will use global Global- applies to all repositories for the current user > Syntax: git config --global user.name or user.email.

-mkdir (make directory) name – creates a new directories for example: my_project in your machine.

-git init this tells Git to start tracking this folder,it initializes git on the folder,the .git folder is where all the history, settings, and saved snapshots lives. It's hidden so you don't accidentally delete it.

-cd moves/change from one directorate to another.

-ls list all the files inside your folder.

-pwd it checks or prints the path of the current working directorate.

-clear clears or removes the display of the terminal window.

-touch creates a file inside a directorate.

We create a README.md file using touch README.md
To know a file is a git repository by default it is called main which happens to be the_ branch assigned_ since you are the creator of the repository.

-echo prints text strings inside the README.md example "hello world"

as it can also be used to write content to a file or create an empty file. To accomplish this, the echo command is utilized in conjunction with single ">" symbol followed by the desired filename we can say then that it can act as a short cut to creating a file.

-git branch list all branches.

-*code * it will open your vs code automatically under the main.py file.

To view the VS code “Hello! World on the terminal/git bash we can use python main.py or py main.py

-git clone downloads a repository that already exists on GitHub to our computers this includes all of the files, branches, and commits. This is done by coping the URL to your git bash.

-git add (the file name) This will add a specific file to the staging area.

-git commit -m ‘’’message’’-used to save the currently staged changes into the local repository and provides a massage that describe the changes made for future reference.

-git status Shows which files are staged and ready to commit

-git pull downloads/update all changes from GitHub(remote repository)into our computer.

-git push origin main pushes the changes(commits) from our local repository to GitHub.

Top comments (0)