Git is a Version Control System that is widely used for software development and other collaborative projects. It allows multiple people to work on the same codebase, tracking changes and maintaining a history of all changes made to the code. Git makes it easy to manage multiple versions of the codebase, track bugs, and merge changes made by different people into a single, unified codebase.
In Git, every change made to the codebase is recorded as a "commit." Each commit has a unique identifier, called a "hash," that can be used to reference that specific version of the code. Commits can be organized into "branches," which allow different versions of the code to be developed and tested in parallel. When changes are ready to be merged into the main branch, they can be "merged" using Git's built-in merging tools.
Git also supports distributed collaboration, allowing developers to work on the same codebase from different locations and to share changes with each other by "pushing" and "pulling" changes between repositories. This makes it easy for developers to work together, even if they are separated by large distances.
Git uses a command line interface, and the syntax for Git commands typically consists of the command name followed by one or more options and/or arguments.
Here are some commonly used Git commands and their syntax:
In Git, a "branch" is a separate line of development within a Git repository. Each branch can contain its own set of commits, allowing multiple versions of the code to be developed and tested in parallel. This makes it easy to work on new features, fix bugs, or experiment with different approaches, without affecting the main line of development.
By default, Git repositories have a single branch named "master," which is considered the main branch. When you make changes and commit them, those changes are recorded on the "master" branch.
You can create new branches by using the "git branch" command, and switch between branches using the "git checkout" command. For example, to create a new branch named "feature," you would run "git branch feature", and to switch to that branch, you would run "git checkout feature".
Once you have made changes on a branch, you can merge those changes back into the main branch, or another branch, using the "git merge" command. For example, to merge changes from the "feature" branch back into the "master" branch, you would switch to the "master" branch using "git checkout master", and then run "git merge feature".
A "remote repository" in Git is a version of a Git repository that is stored on a remote server, rather than on the local computer. Remote repositories can be used to store backups of your code, or to allow multiple people to collaborate on the same codebase.
When you clone a Git repository, you make a local copy of the repository on your computer. By default, this local repository is connected to the original remote repository, and you can use the "git push" and "git pull" commands to transfer changes between the two.
For example, you might make changes to the code on your local repository and then "push" those changes to the remote repository, making them available to others. Conversely, you can "pull" changes that others have made to the remote repository down to your local repository.
Having a remote repository makes it easy to collaborate with others on a shared codebase, as well as to keep a backup of your code that is stored off your local computer. There are many hosting services, such as GitHub and GitLab, that provide hosting for remote Git repositories, and make it easy to manage and collaborate on Git projects.
Status:: #wiki/notes/mature
Plantations:: Software Development - 20230221103859
References:: ILOG, Fundations of Git - Certification Course