What is git?
Git tutorial explains basics about git. Git is a distributed sub version control system (DSVC). Git is very popular for its features. Git was originally developed by Linus Torvalds , for linux kernel development. For a larger scale of software development , a sub version control system (SVC) is highly effective for parallel development, Track changes, branching, merge etc. A central copy of code is maintained called repository.
For example, in a company there are 10 software developers , working on same project in parallel each one developing modules those are interconnected . Once a feature is completed (e.g developed , git commit and git push ) by one developer this will be automatically available to others. If SVC is not used , other developers has to take/merger the code manually . In case of conflict (at same place in code two developers has written) between two development, SVC shows both the codes and developer can manually merge (select correct code) and can update (git push) in central repository. SVC maintains a set of files for a version , any point of time the set of files can be retrieved. When any change in SVC is made ( source file is added or modified) the version number changes or advances.
Central, sub version control (SVC): A central copy called repository is maintained on a machine. If any user commit the changes the central copy is updated.
Distributed SVC : Every user have full copy of repository (git clone command) on local machine , along with central repository. Local copy have full history of changes. All operation (branching , merging etc.) can be done on local copy , so even there is no internet access all SVC things can be done. When a commit (git commit) is done , it changes the local repository copy. If the changes has to available to other users the central copy is updated (git push command). Other users can update local copy by git pull.
Git commands :
- git init , creating for new repository.
- git merge command merge the code from a branch to the current working branch. If git merge gives conflicts, then conflicts should be resolved manually.
- git clone command, creates full copy of repository on local machine. Local repository have all full history of all changes.
- git push command , if a user works on local repository. When code changes needs to updated on central repository git push is used.
- git checkout command, enables the user to switch from one branch to other or to create a new branch and switch to new branch. . The git branch can list the all branches and with git checkout uses can switch to a branch.
- git pull, command updates the local copy from central repository. It do code download and do git merge.
- git branch command displays all branch is current local repository.
- git revert command perform undo changes.
- git add command prepare the staging area for next commit
- Full git repository can be recovered from any local repository in case of case of central repository failure.
- Branches are light weight in git , as they have only reference for change codes , not the full copy.
- There is staging area in git, this area can be prepared for next commit. Can add files or directories for next commit.
- Distributed in nature , highly effective for parallel development. Offline users can also take full advantages of a source control system.
- Accountability , git does details logging for every commit. A user who commits can traced easily.