WHAT IS GIT?
The git clone command copies an existing Git Repository. Cloning always creates a remote connection called origin pointing back to the original repository. This makes it very easy to work with the central repository.
The below command will clone the repository “https://github.com/suddeb/TestRepository.git” to the folder TestRepo in my local machine.
The git config command will configure the Git installation from the command line.
Below command will configure the Author name to be used for all commits in the current repository by the current user.
git config –global user.name “Sudipta Deb”
Below command will configure the Author email to be used for all commits in the current repository by the current user.
git config –global user.email “email@example.com”
The git add command adds a change in the working directory to the staging area. Basically, it will inform git that you want to include this change in your next commit.
Below command will add the file “test.txt” from working directory to staging area making it available for next commit.
git add test.txt
Here is the screenshot of my command prompt:
So if you see once I changed the test.txt file, git status command is telling me that I have changes not staged for commit. After that, I have used the command git add test.txt to add the file to staging area. Once done, issues the command git status is telling me something different that I have now changes ready to be committed.
The git commit command commits the staged snapshot to the project history. Below is the command which will commit the previously staged file test.txt into local repository. Don’t be confused? I will explain what is local repository very soon.
git commit -m “My First Commit”
So once your commit is done, if you issue git status it will tell you that you have nothing in the staging environment to be committed.
WHAT IS LOCAL REPOSITORY?
In Git, snapshots are always committed to local repository. This is one of the fundamental difference between Git and SVN/CVS. In SVN/CVS, you will always commit against the central repository, whereas in Git you don’t need to interact with central repository until and unless you are ready to do that. All your commits are stored in the local repository. Consider staging area as the buffer between your workspace and project history, similarly each developer’s local repository is the buffer between their contribution and central repository.
There are some other fundamental differences between Git and SVN. Where SVN tracks the differences of a file, Git’s version control mechanism is based on snapshots. Below picture will help you to understand the differences between SVN/CVS(Centralised Version Control System) and GIT(Distributed Version Control System)
In my next post, I will talk about Git Stash. One of my favorite command and you can play with this command. Till then, enjoy version controlling. Provide me your feedback. Thanks.