Git, is a source code versioning system that lets you locally track changes and push or pull changes from remote resources. A git repository is a central place where developers store, share, test and collaborate on web projects. GitLab, GitHub, and Bitbucket are services that provide remote access to Git repositories. Sourcetree is a Git GUI that offers a visual representation of your repositories. It is a free Git client.

How it works — Big Picture of GIT

We have repositories either in remote locations or on the local machine itself. In the repository in the local machine we called, local repo & any developer who is in working with git can push changes into a central copy of the repository called, remote repo.

Git commands that are used infrequently.

Clone: Creates a local copy of the remote repository

Branch: Creates a copy of the repo to work without disturbing others

Commit: Commit changes to the local repository

Add: Adds files to the staging area for Git before a file is available to commit to a repository.

Checkout: Switches your local checkout between branches

Push: Moves local changes to the server

Merge: Merges content between branches

Pull: Get changes from the remote server and merge them to the local checkout

Fetch: Get changes from the remote server without merging them

Remote: To connect a local repository with a remote repository.

Stash: The git stash command takes your uncommitted changes (both staged and unstaged), saves them away for later use, and then reverts them from working copy.

Rebase: Inserts the changes from the base into the branch

Git Rebase

You may use the rebase command to take all the changes made on one branch and replay them on another branch. Let’s see rebase graphically.

Status of the file

In any version control system, the main resource would be the source files. The copy of the file that has in your local machine is called the working copy & it will hold the files of your project. Untracked files & Tracked files are the two types of files.

Creating Branches

On top of an existing branch, we can make a new branch. To achieve this, we’ll need the name of an existing branch. To see all the branches in the repository, use the Git branch command with the -a flag. To establish a new branch based on an existing branch, use the Git Branch or Git Checkout commands with the name of the existing branch.

How to work with GIT, Step by Step

* Fork the project — Your server-side copy of the project

* Clone the repository that was forked — Gives a working copy of the project on the local machine

* Create a new feature — We need to create a branch

* Add files

* Commit to the local repo

* Once the feature is developed, push the branch to the remote repository

* Create a pull request

* Review Code, Accept the Merge

* Merge to the master

* Close the pull request



Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pasindu Rukshan Fernando

Pasindu Rukshan Fernando

Software Engineering Undergraduate at SLIIT.