Git is an open source version control system.It offers lots of useful features expected in any version control system.
- We can work in offline mode in Git,this means that even if we are not connected to the network,we can still commit our changes in the local repository.Once we are connected to the network we push our changes to the main repository.This is because Git is a distributed version control system.
- As we commit our changes locally ,this has the advantage of being able to commit our changes frequently.
- As every change is tracked we can easily revert the commit and undo the changes.
Git Bash is the command line for Git.On the Git bash user types different Git commands for the action he wants to perform.At the command prompt we type git followed by command name.Just typing git will display the information on using the git bash.
Some Important commands
The below command will update the files in the working directory to match the <commit> commit.
git checkout <commit>
For example to get back to the master branch following command can be used
git checkout master
This command is used to revert the changes done in a commit.The following command will undo the changes done in the commit and will apply it to the current branch.
git revert <commit>
This is used to remove untracked file from the working directory
git clean -n
Since Git is a version control or source control system it is useful to get familiar to these terms when working with Git:
Version control systems are used to manage the revisions or changes made to the files.Each file can have different version number which represents the state
of the file.It is part of the software configuration management which represents the tasks related to tracking changes to the software.
Centralised version control systems There is a central server which contains all the version of the files/source code.All users are expected to commit their changes to the central server.The disadvantage is that if the central server is offline users can not commit their changes.Examples of
this type of version control system are Subversion and Perforce.
Distributed version control systems As opposed to client server version control systems ,in which there is central repository on the server ,in distributed version control systems each users working copy contains all the versions of the files.This results in better performance as user is
not required to communicate with the central server for every commit.Git is a distributed version control system.
Repository Stores a collection of files and also records the changes to the files in the form of metadata.
It is useful to keep multiple copies of the files for better management.Trunk is the base version of the source code.Branch is the version of the source code in which new features are added.So we can have one branch representing one feature and another branch representing another feature.
For example if we are working on a new feature in Git we will create a new branch for that feature and when we are done working on it we will merge it with the main branch.
Git for the windows platform can be installed from the following location http://msysgit.github.com.