Introduction to Git
Learning new things can be overwhelming at times, there is a lot to explore and we often get lost in the vast ocean of topics and eventually lose the interest.
Same happened to me when I started coding(except I did not lose the interest) , Git and Github seemed to be very confusing at first, with time when you start using them regularly it becomes just another thing for you.
Git is an open-source, version- control software used to maintain the changes in our code. While Github on the other hand is a software for collaboration of all the Git repositories. It is made around the core Git functionality but also has additional features the the Git does not offer.
Core terminologies that form Git’s workflow:
REPOSITORY (REPO): A folder or directory that stores our projects and full history of the changes made. The repository can be saved on a local device or remotely on Github.
CLONE: Creating a local copy of the repository on Github. The
git clonecommand is used for this purpose.COMMIT: A change made to the repository, can also be called as the “snapshot“ of our project at a specific time. It is identified by a unique SHA hash and a message describing the changes.
BRANCH: A separate line of the main code(a copy) where changes can be made independently without affecting the main code. Great for experimentation.
FETCH: Download files or commits from a remote repository to your local one separately.
MERGE: Integrating changes from one branch to another.
PUSH: Changes are made in the local repository and updates are sent to the remote repository.
PULL: Combines ‘fetch‘ and ‘merge‘, downloads content from remote repository and immediately update the local repository.
PULL REQUEST: Github allows the developers to discuss changes in their codes and if approved the changes are merged in the main code.
Common GIT commands:
git init: initialise a new local repository.
git clone [url]: creates a local copy of the remote repository.
git status: monitor the state of your working directory.
git add [file]: adds a file (or files) to the staging area, preparing the changes to be included in the next commit. Use git add . to stage all changes.
git commit -m "[message]": save staged changes as a commit.
git log: displays change history.
Workflow:
All git workflows involve 3 main areas:
Working Directory: the local file where we edit our files, the changes made here are not tracked by the Git yet.
Staging Area: also known as index, a place to add changes using git add and preview it before committing them to the repository. A kind of “waiting room”.
Local Repository: also known as HEAD, the place where Git permanently stores the changes, changes move here from the staging area using git commit. It is our machine that we work upon.
Remote Repository: a version of Git that is up on the internet such as GitHub. Here people collaborate with their code and synchronise their work. It is only used for sharing and exchanging codes.

image: Molly Nemerever, Git, Github and Workflow Fundamentals.11th March, 2019