Git ~ Introduction - rohit120582sharma/Documentation GitHub Wiki

Git is an open source, distributed version control system that allow you to store your code or program on cloud. It also offers features that makes it easy for multiple people to work on same code base.

Each Git repository is tied to a specific directory - the directory where you ran git init. Only files from that directory (and sub-directories inside that directory) will be contained in that repository, and you can have different repositories in different directories.

References



Solution of major problems

Hard-disk failure

Git saves the code on cloud and synch the files to your local computer. The cloud is basically some remote machine which is much more stable than your local computer.

Multi-user contribution

Multi-user have a copy of code on their individual computers and can work on local files offline. Whenever they are ready, they can push those changes to cloud over the internet. If multi-user are working on same file and pushing updates to cloud; then they can use merge tool to resolve the conflicts.

Version tracking

VCS (Version Control System) maintains version history, you can revert to any of the previous state of your code. GIT is a distributed version control system where the version history is maintained on your local computer as well as it is maintained on cloud.



Internal state management system

Working directory

It is in sync with the local filesystem and is representative of the immediate changes made to content in files and directories.

Staging index

It as a buffer between the working directory and the project history. It tracks "Working Directory" changes, that have been promoted with git add, to be stored in the next commit. It is a complex internal caching mechanism.

Local repository

Instead of making a change and committing it directly to the central repo, Git developers have the opportunity to accumulate commits in their local repo. The git commit command adds changes to a permanent snapshot that lives in the Commit History. Git Snapshots are always committed to the local repository.



Terms

Repository

A repository is the most basic element of Git and GitHub. Imagine it as a project's folder. A repository contains all of the project files (including documentation), and stores each file's revision history.

Commit

An individual change to a file (or set of files). With Git, every time you save it creates a unique ID (a.k.a. the "SHA" or "hash") that allows you to keep record of what changes were made, when and by who. Commits usually contain a commit message which is a brief description the changes made.

Branch

A parallel version of repository. It is contained within the repository, but does not affect the primary or master branch allowing you to work freely without disrupting the "live" version.

Remote

The connection of a local repository with one on GitHub. It permits revision history to be synchronized by publishing local commits and downloading any new changes from GitHub.

Flags

  • -a / --all
  • -d
  • -e / --edit
  • -f / --force
  • -i
  • -n / --no-commit
  • -u / --include-untracked
  • -x

⚠️ **GitHub.com Fallback** ⚠️