GIT

Git is one of the free and open-source distributed version control systems. Git is responsible for everything happens on GitHub related locally on the computer.

Git helps us manage our project files. It permits to work together on the same project and at the same time without disturbing each other’s files. Collaboration is easy with Git. All the Team members can work on different features and easily merge all changes.

Some basic terminology used in Git:

1. Repository: 

A repository might be a storage space where you can go live for your projects. Most of the time GitHub users abbreviate this to “repo”. It is a local folder on your computer or storage space on GitHub. You can store code records, content records and picture records inside a repository.

To create a new repository, go to the new repository option and provide a short and memorable name. You can change the settings, private or public access.

There are three forms in which a repository can be started:

    1. Open – Open a repository as already opened or initialized, and which is usually available locally

    2. Clone – Clone a remote Git repository as of now initialized.

    3. Init – Create an empty repository and open a local project repository.

2. Open:

To load and pick up your existing folder where you left. It is also useful to see past work which is completed. To start opening File->Open Repo.

3. Clone:

A clone is basically a copy of a repository that lives on your computer rather than on a server. To start opening File->Clone Repo.

    Using Command:

      git clone [URL of the repo]

4. Init:

Init call helps Initialize, a new project and local project. Moreover, Starting a project is easy through File->Init.

    Using Command:

      git init [repository name]

5. Branch:

For one project to create multiple branches. The branch is used by more than one developer. They can work at the same time, but that work does not go live on the main remote repository. Thay can point to commit a specific branch in the repo. After merge off of the main branch with their own changes ( changes made by them). The master of the project is the main remote directory.

When you are creating a new branch, your changes, live on that branch does not affect the master branch. Anything in the master branch is always Deployable.

    Using Command:

      git branch [branch name]

    For switch from one branch to another branch:

      Git checkout [branch name]

    For merging the specific branch history into the current branch:

      git merge [branch name]

6. Commit:

It is the power command of the Git. Commit is also used as Push. It takes local changes and make them live on the remote. Changes pushed on currently checked out of the branch on clicking to the top toolbar.

    Using Command:

      git commit -m “[commit message]”

7. Pull:

Remote pulling updates and bringing them into your local folder.

There are 4 pulling types:

    1. Fetch All: Getting updates from remote sites, but not bringing any of these new data into your working file. Fetch is nice to get a fresh look at all the things that has happened in a remote repository.

      Using Command:

      git fetch –all

    2. Pull (fast-forward if possible): Pull will get any updates on the remote branch and then try to move the local branch forward quickly. This is GitKraken’s default option for users.

      Using Command:

      git pull [Repository link]

    3. Pull (fast-forward only): Pull (fast-forward only) gets all updates and then tries to move fast-forward.

      Using Command:

      git fetch –ff-only

    4. Pull (rebase): Pull stashes all commits on this branch, pulls through new commits from the remote and then replays the commits.

      Using Command:

      git fetch –rebase

8. Pull Requests:

Pull Requests initiate a discussion about your commits. Since they tightly coordinate with the basic Git store, anybody can see precisely what changes would be combined in case they accept your task. Pull Requests are valuable for contributing to open source projects and for overseeing changes to be shared on repositories. Pull Requests is basically a code review process.

9. Undo and Redo:

To remove the last commit from git to use Undo. For revert undo changes use Redo.

    Using Command:

      git reset HEAD^

      git reset HEAD~2 (for remove multiple commits)

10. Stash:

Stash is used for storing safely and secretly in a specified place. Reserved changes show up within the cleared out Stash board, where any stash can be connected, popped or deleted.

    Using Command:

      git stash save

11. Pop:

Pop is vice versa of stash. It is used to restore the most recently stashed files.

    Using Command:

      git stash pop

12. Git Folder:

When initializing a Git repo or cloning from a remote, you may notice a .git folder in the project root. This contains all of the data required for the Git repository and if this folder is deleted, you’d now not be able to switch branches, pull from remotes, or view commit history.