Git is a Distributed Version Control System that records changes to a file over time so that you can recall specific versions later. The main advantage of Git over other VCSs is that we can do most of the operations in Git offline and hence Git is a much faster VCS. Using Git, our files can reside in any one of the three states: committed, modified and staged.
Committed means that data is safely stored in the local database
Modified means that we have changed the file but have
not committed it to the database yet.
not committed it to the database yet.
Staged means that we have marked a modified file in its current version to go into the next commit snapshot.
Installing Git and Configuring the settings:
To install Git in Linux, we have to run the following command:
$ apt-get install git-core
To install Git on various other operating systems, please refer to more details
After installing, the next step is to configure the settings where you have to provide your identity such as name and email address. Following commands are used for this purpose
$ git config --global user.name"Your name here"
# Sets the default name for git to you commit
$ git config --global user.email "Your email@youremail.com"
# Sets the default email for git to use when you commit
Note that your email address for Git should be the same one associated with your GitHub account.
How to use a git repository:
Now we have installed Git and configured the settings. We can now start using Git to store and share our codes.We can get a git repository in two ways, first is to import an existing directory and the second method clones an existing git repository from an another server.
To initialize a repository in an existing directory, goto to the projects directory and type the following commands.
$ git init
$ git add <filename>
$ git commit m ’initial project version’
$ git add <filename>
$ git commit m ’initial project version’
To clone a repository, use the following command,
$ git clone [url]
After we have committed all the changes, we have to push the files to a remote repository. Use the commands:
$ git push [remote-name] [branch-name]
$ git push origin master
To check the status of our working directory and to know which files are in which states, use
$ git status
After we have created several committs and if we want to look back what has happened over the time, use
$ git log
These are some basic ideas regarding Git. Please refer GIT for the complete details.
Comments
Post a Comment